Subject: Re: [xsl] opposite of preceding-sibling From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 10 Aug 2001 16:23:18 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] opposite of preceding-sibling, Jan Weiss | Thread | [xsl] putting spaces into documents, Rakesh Aswal |
Re: [xsl] follow up re: key executi, Trevor Nash | Date | Re: [xsl] Capitalizing content of a, Goetz Bock |
Month |