Subject: RE: [xsl] Squire bracket is getting duplicate. From: "JS rawat" <jrawat@xxxxxxxxxxxxxx> Date: Tue, 22 Mar 2011 18:14:03 +0530 |
Seems good!!! But are not able to integrate it within my existing template. I am using below for para element. <xsl:template match="para"> <p> <xsl:call-template name="id"/> <xsl:apply-templates/> </p> </xsl:template> -----Original Message----- From: Syd Bauman [mailto:Syd_Bauman@xxxxxxxxx] Sent: Tuesday, March 22, 2011 5:02 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Squire bracket is getting duplicate. Not sure if you are using XSLT 2 or are restricted to XSLT 1. The following XSLT 1 seems to work with rudimentary tests. The idea is simple: when you hit a text node that is both immediately before (after) an element for which we plan to add brackets AND it ends in (starts with) a square bracket, write out the text node without the offending bracket. <xsl:template match="text()[following-sibling::node()[1][self::citationref]][substring(.,s tring-length(.),1)='[']"> <xsl:value-of select="substring(.,1,string-length(.)-1)"/> </xsl:template> <xsl:template match="text()[preceding-sibling::node()[1][self::citationref]][substring(.,1 ,1)=']']"> <xsl:value-of select="substring(.,2)"/> </xsl:template> Others on this list may be able to provide you with better, or at least prettier, versions of that. And certainly it's a lot nicer if you're using XSLT 2. (Although you have to mind your escaping of square bracket, a special character to the regular expression language XSLT uses.) > Hi Team, > > Is there any logic by which duplicate squire bracket can be avoided > ([<xref><sup>[2]</sup></xref>]) . Below are input and output > > XSLT: > <xsl:template match="citationref"> > <xref> > <xsl:attribute name="rid"><xsl:value-of > select="@linkend"/></xsl:attribute> > <xsl:attribute name="ref-type">bibr</xsl:attribute> > <sup> > <xsl:text>[</xsl:text> > <xsl:apply-templates/> > <xsl:text>]</xsl:text> > </sup> > </xref> > </xsl:template> > > Input: > <para>Once ... <citationref linkend="cit379-1">1</citationref>. The > ...[<citationref linkend="cit379-2">2</citationref>].</p> > > Output: > <p>Once ... <xref rid="cit379-1" > ref-type="bibr"><sup>[1]</sup></xref>. The ...[<xref rid="cit379-2" > ref-type="bibr"><sup>[2]</sup></xref>].</para> > > Required Output: > <p>Once ... <xref rid="cit379-1" > ref-type="bibr"><sup>[1]</sup></xref>. The ...<xref rid="cit379-2" > ref-type="bibr"><sup>[2]</sup></xref>.</p> BTW, I hope that you mean <para> and </para> OR <p> and </p> in all cases ... this is not well-formed as it sits.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Squire bracket is getting, Syd Bauman | Thread | RE: [xsl] Squire bracket is getting, Syd Bauman |
Re: [xsl] Squire bracket is getting, Syd Bauman | Date | RE: [xsl] Squire bracket is getting, Syd Bauman |
Month |