[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: is there a more elegant way to change page refere
At 2012-05-28 11:42 -0400, Terry Ofner wrote:
I have an xml document with multiple page references inside <ref> elements. I have to add 2 to each page reference that follows the text TG:
. . . . . . . . . Ken t:\ftemp>type terry.xml <?xml version="1.0" encoding="UTF-8"?> <ref><b>TG: </b>pp. 19, 20, 21, 29, 32, 40, 43, 44, 46, 56, 57, 58, 60, 61, 66, 67–68</ref> t:\ftemp>xslt2 terry.xml terry.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, 69GGt70</ref> t:\ftemp>type terry.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template match="@*|node()"><!--identity for all other nodes--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!--the following assumes that any given string of page numbers is not interrupted--> <xsl:template match="ref/text()"> <xsl:analyze-string select="." regex="(\d+)(–(\d+))?"> <xsl:matching-substring> <xsl:value-of select="number(regex-group(1))+2"/> <xsl:if test="regex-group(2)"> <xsl:text/>–<xsl:value-of select="number(regex-group(3))+2"/> </xsl:if> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:template> </xsl:stylesheet> t:\ftemp> -- Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|