xsl-list
[Top] [All Lists]

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

2012-05-28 11:11:26
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, 69–70</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. ________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>