Subject: RE: [xsl] Grouping and Numbering From: "Angela Williams" <Angela.Williams@xxxxxxxxxxxxxxxxxx> Date: Fri, 25 May 2007 15:08:58 -0500 |
I'm not versed in the 1.0 limitations, but I'm using something like this in 2.0 for the same reason: <xsl:variable name="tmp-table"> <xsl:apply-templates select="sample//result/details"> <xsl:sort select="group_id" data-type="number" /> </xsl:apply-templates> </xsl:variable> <xsl:variable name="sorted-and-grouped"> <xsl:for-each select="$tmp-table"> <!-- logic to insert extra row here.... Your node-set would look like this: <output>250</output> <output>250</output> <output /> <output>300</output> --> </xsl:for-each> </xsl:variable> <xsl:for-each select="$sorted-and-grouped"> <xsl:copy-of select="."/> <xsl:attribute name="row" select="position()"/> </xsl:for-each> This works fine, but if someone has a more efficient / elegant solution, I would love to know it.... Hope this helps! Angela Williams Software Developer The 401k Company, A Charles Schwab Company 98 San Jacinto Blvd. ~ Suite 1100 ~ Austin, TX 78701 Office: 512.344.1547 ~ Fax: 512.397.6656 Angela.Williams@xxxxxxxxxxxxxxxxxx -----Original Message----- From: Carl Radley [mailto:Carl.Radley@xxxxxxxxxxx] Sent: Friday, May 25, 2007 4:21 AM To: XSL List (Mulberry Tech) (E-mail) Subject: [xsl] Grouping and Numbering Hi, I'm using XSLT version 1, so can't use grouping. I need to run through a large structure that resembles: <sample> <result> <details> <group_id>250</group_id> </details> </result> <result> <details> <group_id>300</group_id> </details> </result> <result> <details> <group_id>250</group_id> </details> </result> </sample> Firstly, I need to sort the data into <group_id> order, so I use: <xsl:apply-templates select="sample//result/details"> <xsl:sort select="group_id" data-type="number" /> </xsl:apply-templates> Next, within the called template, I need to loop through all the <details> and add row numbering information but add an extra row at the end of each group. So hope to see: <output row="1">250</output> <output row="2">250</output> <output row="3" /> <output row="4">300</output> First problem is that, when I check "preceding::details[1]/group_id" it refers to the original document layout and not the sorted order, so I get: <output row="1">250</output> <output row="2" /> <output row="3">250</output> <output row="4" /> <output row="5">300</output> Second problem is remembering the row count, since I need to add several additional rows during the loop, so "position()" goes out of sync. I've tried to call another template, passing in the <group_id> and determine it's sorted position but have not been able to get a unique list because of my first problem. Hope I've made this as concise as possible. Thanks in advance, Carl ---------------------------------------------------------------- This e-mail (which includes any files attached to it) is not contractually binding on its own, it is intended solely for the named recipient and may contain CONFIDENTIAL, legally privileged or trade secret information protected by law. If you have received this message in error please delete it and notify us immediately by telephoning +44(0)2476421213. If you are not the intended recipient you must not use, disclose, distribute, reproduce, retransmit, retain or rely on any information contained in this e-mail. Please note that Severn Trent Laboratories Limited reserve the right to monitor email communications in accordance with applicable law and regulations. To the extent permitted by law, neither Severn Trent Laboratories Limited or any of its subsidiaries, nor any employee, director or officer thereof, accepts any liability whatsoever in relation to this e-mail including liability arising from any external breach of security or confidentiality or for virus infection or for statements made by the sender as these are not necessarily made on behalf of Severn Trent Laboratories Limited. Severn Trent Laboratories Limited is a limited company registered in England and Wales under registered number 2148934 with its registered office at 2297 Coventry Road, Birmingham B26 3PU. -----------------------------------------------------------------------
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Grouping and Numbering, Carl Radley | Thread | [xsl] Page numbering, Andy Carr1 |
RE: [xsl] Page numbering, Angela Williams | Date | Re: [xsl] Grouping and Numbering, David Carlisle |
Month |