Re: [xsl] is there a more elegant way to change page references?

Subject: Re: [xsl] is there a more elegant way to change page references?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 28 May 2012 17:11:03 +0100
On 28/05/2012 16:42, Terry Ofner wrote:
<ref><b>TG:</b>pp. 19, 20, 21, 29, 32, 40, 43, 44, 46, 56, 57, 58, 60, 61, 66, 67&#8211;68</ref>



<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>


<xsl:template match="ref[b='TG: ']">
<ref>
<xsl:copy-of select="b"/>
<xsl:analyze-string select="b/following-sibling::text()" regex="[0-9]+">
<xsl:matching-substring>
 <xsl:value-of select="number(.)+2"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</ref>
</xsl:template>
</xsl:stylesheet>

produces:

$ saxon9 ref.xml ref.xsl
<?xml version="1.0" encoding="UTF-8"?><ref><b>TG: </b>pp. 21, 22, 23, 31, 34, 42, 45, 46, 48, 58, 59, 60, 62, 63, 68, 6970</ref>


David


________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread