Thanks Mukul.
But I think there will be empty tags if there is no elements present
such as if publication type is book,thesis,report then there are
different types of tags like publisher-loc,publisher-name
Is there any way that i can separately match each template and pass
element in the new tree so that if the tag is present then only new
element is created n tagged For ex in above example
<xsl:template match ="ref">
<xsl:element name ="bibentry">
<xsl:apply templates/>
</xsl:element>
</xsl:template>
<xsl:template match ="mixed-citation/name">
<xsl:element name ="author">
<xsl:apply templates/>
</xsl:element>
</xsl:template>
<xsl:template match ="mixed-citation/given-names">
<xsl:element name ="fname">
<xsl:apply templates/>
</xsl:element>
</xsl:template>
<xsl:template match ="mixed-citation/given-names">
<xsl:element name ="fname">
<xsl:apply templates/>
</xsl:element>
</xsl:template>
I face 2 problems First is including Authorgrp tag and pagefield tag
second If i apply templates within template matching ref,i can insert
authorgp and pagefield but cannot tag text()as x accordingly
On Mon, Oct 25, 2010 at 4:02 PM, Mukul Gandhi
<gandhi(_dot_)mukul(_at_)gmail(_dot_)com> wrote:
I would suggest a stylesheet something like below:
(this is of 2.0 flavor, incomplete -- but i believes gives a fair idea
of the algorithm i have in mind, and untested)
<!-- identity template -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<xsl:template match="ref">
<bibentry type="{concat('bib', label)}" publication="{if
(mixed-citation/@publication-type) =
'journal' then 'jurnl' else ()}">
<xsl:apply-templates/>
</bibentry>
</xsl:template>
<xsl:template match="label">
<num>
<xsl:value-of select="." />
</num>
</xsl:template>
<xsl:template match="mixed-citation">
<authorgrp>
<xsl:for-each select="name">
<author>
<xsl:copy-of select="surname" />
<fname>
<xsl:value-of select="given-names" />
</fname>
</author>
</xsl:for-each>
</authorgrp>
<article type="title">
<xsl:value-of select="article-title" />
</article>
<article type="jurnl">
<xsl:value-of select="source" />
</article>
<!--
to write something more here.
-->
</xsl:template>
<xsl:template match="text()[not(normalize-space(.) =
'-')][preceding-sibling::node()[1]/self::*]">
<x><xsl:value-of select="normalize-space(.)" /></x>
</xsl:template>
On Mon, Oct 25, 2010 at 1:45 AM, chirag matkar
<chiragmatkarbioinfo(_at_)gmail(_dot_)com> wrote:
Input is
<ref id="B5">
<label>5</label>
<mixed-citation publication-type="journal">
<name>
<surname>Kaplan</surname>,
<given-names>SH</given-names>
</name>;
<name>
<surname>Greenfield</surname>,
<given-names>S</given-names>
</name>;
<name>
<surname>Ware</surname>,
<given-names>JE</given-names>
</name>.
<article-title>Assessing the effects of physician-patient
interactions on the outcome of chronic disease</article-title>,
<source>Med Care</source>,
<year>1989</year>,
<volume>27</volume>,
<supplement>suppl 3</supplement>,
<fpage>110</fpage>-
<lpage>125</lpage>
</mixed-citation>
</ref>
Required output
<bibentry type="bib5" publication="jurnl">
<num>5</num>
<authorgrp>
<author>
<surname>Kaplan</surname><x>,</x>
<fname>SH</fname>
</author><x>;</x>
<author>
<surname>Greenfield</surname><x>,</x>
<fname>S</fname>
</author><x>,</x>
<author>
<surname>Ware</surname><x>,</x>
<fname>JE</fname>
</author><x>.</x>
</authorgrp>
<article type="title">Assessing the effects of
physician-patient interactions on the outcome of chronic
disease</article-title>,
<article type="jurnl">Med Care</article><x>,</x>
<date year="1989"> 1989</date><x>,</x>
<volnum>27</volnum><x>,</x>
<pagefield>
<fpage>110</fpage>-
<lpage>125</lpage>
</pagefield>
</bibentry>
In output Mainly except - ,everthing else like . , ; should come under <x>
tag
Also the input of , , ; can be random
I have use apply templates sequentially for authorgrp and others but
the random input of . , ; is not tagged inside <x>
--
Regards,
Chirag Matkar
--
Regards,
Mukul Gandhi
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--
Regards,
Chirag Matkar
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--