| | |
Repeat header when NODE changes (compare with previous-sibling)
![]() |
•
•
Join Date: Sep 2008
Posts: 1
Reputation:
Solved Threads: 0
Hello,
this is my XML:
What I need to do is repeat some header everytime ROW_NUM changes. I came this far:
I'm having trouble with writing the condition in red. Can someone give me an advice?
Thanks a lot!
this is my XML:
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<OPTIONS> <ROW NUM="1"> <ROW_NUM>1</ROW_NUM> <INVOICE_NUMBER>000001</INVOICE_NUMBER> <ID>144795</ID> <CUS_UK>20544</CUS_UK> <DESC_LONG>KELEME</DESC_LONG> </ROW> <ROW NUM="2"> <ROW_NUM>1</ROW_NUM> <INVOICE_NUMBER>000001</INVOICE_NUMBER> <ID>69449</ID> <CUS_UK>15249</CUS_UK> <DESC_LONG>PETRIMEX</DESC_LONG> </ROW> <ROW NUM="3"> <ROW_NUM>1</ROW_NUM> <INVOICE_NUMBER>000001</INVOICE_NUMBER> <ID>4125</ID> <CUS_UK>15249</CUS_UK> <DESC_LONG>PETRIMEX</DESC_LONG> </ROW> <ROW NUM="4"> <ROW_NUM>3</ROW_NUM> <INVOICE_NUMBER>000002</INVOICE_NUMBER> <ID>4152</ID> <CUS_UK>15249</CUS_UK> <DESC_LONG>PETRIMEX</DESC_LONG> </ROW> <ROW NUM="5"> <ROW_NUM>3</ROW_NUM> <INVOICE_NUMBER>000002</INVOICE_NUMBER> <ID>69486</ID> <CUS_UK>15249</CUS_UK> <DESC_LONG>PETRIMEX</DESC_LONG> </ROW> </OPTIONS>
What I need to do is repeat some header everytime ROW_NUM changes. I came this far:
<xsl:for-each select="OPTIONS/ROW">
<xsl:choose>
<xsl:when test="position()=1 or preceding-sibling::ROW_NUM/text()[1] != ./ROW_NUM/text()">
<!-- this should match the first row and then every row where ROW_NUM is different form previous -->
</xsl:when>
<xsl:otherwise>
<!-- this should match the rest -->
<xsl:otherwise>
</xsl:choose>
</xsl:for-each>Thanks a lot!
Last edited by qwix123; Sep 16th, 2008 at 5:34 am. Reason: mistype
•
•
Join Date: Jun 2008
Posts: 14
Reputation:
Solved Threads: 2
See this: http://www.dpawson.co.uk/xsl/sect2/N6280.html#d9988e142 and this:http://www.dpawson.co.uk/xsl/sect2/N6461.html
Note that you can do some more efficient (and easier) sorting if you can use XSLT 2.0 using
Note that you can do some more efficient (and easier) sorting if you can use XSLT 2.0 using
xsl-for-each-group() ; check out the "Sorting" and "Grouping" topics here: http://www.dpawson.co.uk/xsl/rev2/rev2.html ![]() |
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Help with converting XML into XML
- Next Thread: XML using VB
Views: 1870 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for XML, XSLT and XPATH





