[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: opposite of preceding-sibling
Hi Jan, To answer your subject-line's question, the opposite of preceding-sibling is following-sibling. It's hard to tell because I can't see how the source XML you gave tied up with the result that you were after, but I think that this is a grouping problem. You want to group the index elements by the artnr element they're associated with in a particular row. So index the row elements by artnr: <xsl:key name="row-by-artnr" match="row" use="artnr" /> That means that if you do: key('row-by-artnr', 'gh') you'll get all the row elements whose child artnr element has the value 'gh'. Then it looks as though you want to create a col element for each unique artnr, with an artnr element inside with a nummer attribute holding the value of the artnr from the original XML. You can do this with: <xsl:for-each select="/test/result/row [count(.|key('row-by-artnr', artnr)[1]) = 1]"> <col> <artnr nummer="{artnr}"> ... </artnr> </col> </xsl:for-each> Within the artnr element, you want to add copies of all the index elements from the row elements with that value for the artnr element. You can retrieve those with the key: <xsl:for-each select="/test/result/row [count(.|key('row-by-artnr', artnr)[1]) = 1]"> <col> <artnr nummer="{artnr}"> <xsl:copy-of select="key('row-by-artnr', artnr)/index" /> </artnr> </col> </xsl:for-each> Of course you could use templates rather than xsl:for-each if you prefer. You can find more on the theory at http://www.jenitennison.com/xslt/grouping/muenchian.html. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|