Re: [xsl] Squire bracket is getting duplicate.

Subject: Re: [xsl] Squire bracket is getting duplicate.
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Tue, 22 Mar 2011 07:31:47 -0400
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(.,string-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