[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: breaking sorted material into subsections

Subject: RE: breaking sorted material into subsections
From: Don Bruey <dbruey@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Sep 2000 15:52:37 -0400
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.