Subject: Re: [xsl] Tagging of text() with using apply templates From: chirag matkar <chiragmatkarbioinfo@xxxxxxxxx> Date: Tue, 26 Oct 2010 18:42:05 +0700 |
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.mukul@xxxxxxxxx> 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() | @*"> > B B <xsl:copy> > B B B B <xsl:apply-templates select="node() | @*" /> > B B </xsl:copy> > </xsl:template> > > <xsl:template match="ref"> > B B <bibentry type="{concat('bib', label)}" publication="{if > (mixed-citation/@publication-type) = > > B B B B 'journal' then 'jurnl' else ()}"> > B B B B B <xsl:apply-templates/> > B B </bibentry> > </xsl:template> > > <xsl:template match="label"> > B B <num> > B B B B <xsl:value-of select="." /> > B B </num> > </xsl:template> > > <xsl:template match="mixed-citation"> > B B B <authorgrp> > B B B B B <xsl:for-each select="name"> > B B B B B B B <author> > B B B B B B B B B <xsl:copy-of select="surname" /> > B B B B B B B B B <fname> > B B B B B B B B B B <xsl:value-of select="given-names" /> > B B B B B B B B B </fname> > B B B B B B B </author> > B B B B B B </xsl:for-each> > B B B B </authorgrp> > B B B B <article type="title"> > B B B B B B <xsl:value-of select="article-title" /> > B B B B B </article> > B B B B B <article type="jurnl"> > B B B B B B B <xsl:value-of select="source" /> > B B B B B </article> > B B B B B <!-- > B B B B B B B to write something more here. > B B B B B --> > </xsl:template> > > <xsl:template match="text()[not(normalize-space(.) = > '-')][preceding-sibling::node()[1]/self::*]"> > B <x><xsl:value-of select="normalize-space(.)" /></x> > </xsl:template> > > On Mon, Oct 25, 2010 at 1:45 AM, chirag matkar > <chiragmatkarbioinfo@xxxxxxxxx> wrote: >> Input is >> B B B B <ref id="B5"> >> B B B B <label>5</label> >> B <mixed-citation publication-type="journal"> >> B B B B B B <name> >> B B B B B B B <surname>Kaplan</surname>, >> B B B B B B B <given-names>SH</given-names> >> B B B B B B </name>; >> B B B B B B <name> >> B B B B B B B <surname>Greenfield</surname>, >> B B B B B B B <given-names>S</given-names> >> B B B B B B </name>; >> B B B B B B <name> >> B B B B B B B <surname>Ware</surname>, >> B B B B B B B <given-names>JE</given-names> >> B B B B B B </name>. >> B B B B B <article-title>Assessing the effects of physician-patient >> interactions on the outcome of chronic disease</article-title>, >> B B B B B <source>Med Care</source>, >> B B B B B <year>1989</year>, >> B B B B B <volume>27</volume>, >> B B B B B <supplement>suppl 3</supplement>, >> B B B B B <fpage>110</fpage>- >> B B B B B <lpage>125</lpage> >> B B B B </mixed-citation> >> B B B </ref> >> >> >> Required output >> >> <bibentry type="bib5" publication="jurnl"> >> B B B B <num>5</num> >> <authorgrp> >> B B B B B B <author> >> B B B B B B B <surname>Kaplan</surname><x>,</x> >> B B B B B B B <fname>SH</fname> >> B B B B B B </author><x>;</x> >> B B B B B <author> >> B B B B B B B <surname>Greenfield</surname><x>,</x> >> B B B B B B B <fname>S</fname> >> B B B B B B </author><x>,</x> >> B B B B B B <author> >> B B B B B B B <surname>Ware</surname><x>,</x> >> B B B B B B B <fname>JE</fname> >> B B B B B B </author><x>.</x> >> </authorgrp> >> B B B B B <article type="title">Assessing the effects of >> physician-patient interactions on the outcome of chronic >> disease</article-title>, >> B B B B B <article type="jurnl">Med Care</article><x>,</x> >> B B B B <date year="1989"> 1989</date><x>,</x> >> B B B B B <volnum>27</volnum><x>,</x> >> B <pagefield> >> B B B B B <fpage>110</fpage>- >> B B B B B <lpage>125</lpage> >> </pagefield> >> B B B </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 B tagged inside <x> >> >> >> -- >> Regards, >> Chirag Matkar > > > > > -- > Regards, > Mukul Gandhi > > -- Regards, Chirag Matkar
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Tagging of text() with us, Mukul Gandhi | Thread | Re: [xsl] Tagging of text() with us, Mukul Gandhi |
Re: [xsl] Elements of Programming S, Martin Honnen | Date | [xsl] Remove Namespace from ouput's, Ramkumar.V |
Month |