[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Creating a tree variable and using it in later pro
Hi Alan, > As you can see, the input XML document comes to me sorted by > <number> and not by <name> (how the document is sorted is not in my > control :-( ). However, I need to have my input sorted by <name> and > I need to access the sorted elements according to a certain > predefined order -for the sake of simplicity, lets say I need to > access alternate names in the sorted list. With your simplified example, you could iterate over the product elements in sorted order, and then test the position() of the product to find the odd ones: <xsl:for-each select="product"> <xsl:sort select="name" /> <xsl:if test="position() mod 2 = 1"> Odd product: <xsl:value-of select="name" /> </xsl:if> </xsl:for-each> The main problem with this is that it's hard to find the next product in the sorted list. Given that you don't want to use an intermediate node set, unfortunately the appropriate solutions are likely to heavily depend on what you *actually* want to do rather than a simplification. For example, if you want to group the products by name, then a grouping solution would be more appropriate, or perhaps your predefined order means that you can pick out the relevant products prior to sorting them by name. Please feel free to post more details about what you're trying to achieve and we'll try to help. Cheers, 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
|