[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: breaking sorted material into subsections
Assuming XML looks something like this (@location left out because question didn't pertain to parent's @location href): <IndexEntryData> <index entry = "Ca">Index1</index> <index entry = "Aaaa">Index1</index> <index entry = "Az">Index1</index> <index entry = "Bz">Index1</index> <index entry = "Abb">Index1</index> <index entry = "Ba">Index1</index> </IndexEntryData> This works in MSXML3 and SAXON <xsl:template match="/"> <xsl:for-each select="//index"> <xsl:sort select="@entry"/> <!-- if first character of @entry attrib of first preceding --> <!-- node is not equal to the context's @entry attrib --> <!-- it's a "break" on first character of @entry --> <!-- this works because we're already sorted by @entry --> <xsl:if test ="substring(preceding::*[1]/@entry, 1, 1) != substring(@entry, 1, 1)"> <H2><xsl:value-of select="substring(@entry, 1, 1)" /></H2> </xsl:if> <p> <a href="{../@location}"> <xsl:value-of select="@entry"/> </a> </p> </xsl:for-each> </xsl:template> More of this type of thing in the FAQ Don > but what I want is something like: > > <H2>A</H2> > Aaaa > Abb > Az > <H2>B</H2> > Ba > Bz > <H2>C</H2> > Ca > 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
|