[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT 1 and grouping numbers by if the following n
At 2014-03-24 07:08 -0700, Mario Madunic wrote:
(using XSLT 1) You can use keys as illustrated below. I hope this helps. . . . . . . . . Ken T:\ftemp>type mario.xml <?xml version="1.0" encoding="UTF-8"?> <as> <a>1</a> <a>3</a> <a>4</a> <a>5</a> <a>7</a> <a>9</a> <a>10</a> </as> T:\ftemp>type mario.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:key name="firsts" match="a" use="generate-id((. | preceding-sibling::a) [not(. = preceding-sibling::a[1] + 1)] [last()])"/> <xsl:output indent="yes"/> <xsl:template match="as"> <groups> <xsl:for-each select="a[key('firsts',generate-id(.))]"> <group> <xsl:copy-of select="key('firsts',generate-id(.))"/> </group> </xsl:for-each> </groups> </xsl:template> </xsl:stylesheet> T:\ftemp>xslt mario.xml mario.xsl <?xml version="1.0" encoding="utf-8"?> <groups> <group> <a>1</a> </group> <group> <a>3</a> <a>4</a> <a>5</a> </group> <group> <a>7</a> </group> <group> <a>9</a> <a>10</a> </group> </groups> T:\ftemp> -- Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 | 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: http://plus.google.com/+GKenHolman-Crane/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
|