Subject: Re: [xsl] number collapsing From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 14 Dec 2004 13:27:29 GMT |
range.xml <a> <r><x>1</x><x>3</x><x>5</x><x>7</x></r> <r><x>1</x><x>2</x><x>3</x><x>4</x></r> <r><x>1</x><x>2</x><x>3</x><x>8</x></r> </a> range.xsl <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="r"> <xsl:text> [</xsl:text> <xsl:for-each-group select="x" group-adjacent="if (position()=1 or .=preceding-sibling::x[1]+1) then -1 else position() "> <xsl:value-of select="."/> <xsl:if test="current-group()[2]"> <xsl:text>-</xsl:text> <xsl:value-of select="current-group()[last()]"/> </xsl:if> <xsl:if test="position()!=last()">,</xsl:if> </xsl:for-each-group> <xsl:text>]</xsl:text> </xsl:template> </xsl:stylesheet> $ java -jar ../saxon8/saxon8.jar range.xml range.xsl <?xml version="1.0" encoding="UTF-8"?> [1,3,5,7] [1-4] [1-3,8] ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] number collapsing, Bruce D'Arcus | Thread | RE: [xsl] number collapsing, Michael Kay |
[xsl] Free XSL editors, Marcelo | Date | RE: [xsl] Free XSL editors, Jim Neff |
Month |