[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Wah? Weird... Clarifying the Schema
A node exists at a particular place in a tree. Sorting changes the order in which nodes are processed, but it doesn't modify the tree, and therefore the axes (which navigate the tree) are unaffected by sorting. > > Why is the code working? Because XSLT sorting is defined to be stable. You are sorting the books by category, and then outputting the first book in each category. The rules for XSLT sorting say that duplicates retain their original order, so the first book in a category after sorting is the same as the first book in the category before sorting. Actually, looking at it again, it would work even if sort order wasn't stable, because the only property of a book that you are outputting is the category, which of course is the same for all the books in a category. Michael Kay http://www.saxonica.com/ > > <xsl:for-each select="catalog/book"> > <xsl:sort select="category" data-type="text" > order="ascending" /> > <xsl:if > test="not(preceding-sibling::book/category = category)"> > <xsl:choose> > <xsl:when test="category = $category"> > <option value="{category}" > selected="true"><xsl:value-of select="category" /></option> > </xsl:when> > <xsl:otherwise> > <option value="{category}"><xsl:value-of > select="category" /></option> > </xsl:otherwise> > </xsl:choose> > </xsl:if> > </xsl:for-each>
|
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
|