XSL - How to match consecutive comma-separated tags

Posted by PocketLogic on Stack Overflow See other posts from Stack Overflow or by PocketLogic
Published on 2011-06-24T15:13:38Z Indexed on 2011/06/27 0:22 UTC
Read the original article Hit count: 225

Filed under:
|

I'm trying to match a series of xml tags that are comma separated, and to then apply an xslt transformation on the whole group of nodes plus text. For example, given the following partial XML:

<p>Some text here
    <xref id="1">1</xref>,
    <xref id="2">2</xref>,
    <xref id="3">3</xref>.
</p>

I would like to end up with:

<p>Some text here <sup>1,2,3</sup>.</p>

A much messier alternate would also be acceptable at this point:

<p>Some text here <sup>1</sup><sup>,</sup><sup>2</sup><sup>,</sup><sup>3</sup>.</p>

I have the transformation to go from a single xref to a sup:

<xsl:template match="xref"">
    <sup><xsl:apply-templates/></sup>
</xsl:template>

But I'm at a loss as to how to match a group of nodes separated by commas.

Thanks.

© Stack Overflow or respective owner

Related posts about xslt

Related posts about xpath