[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: Eric Taylor <Eric.Taylor@xxxxxxxxxxxx>
Date: Thu, 21 Sep 2000 06:54:07 -0500
xsl section breaking
Thanks Oliver.  Using translate as you suggested to determine if the initial
character was one of a set worked well.  However, I'm running into one more
minor problem.  None of my attempts to add a section heading for this
Numbers & Symbols work right (either the heading is repeated multiple times
(once for the 1's, again for the 2's, etc.), or it appear even when there is
nothing in the section, or it don't appear at all).  Here's the current
code:

<xsl:template match="pages">

                    <!-- problem with following if -->
                         <!-- I'm aware that I'm only checking the first
@entry  -->
                         <!-- in the data, resulting in the heading
generally    -->
                         <!-- not appearing when it should, but I can't
figure   -->
                         <!-- out how to check them all in this context
-->

  <xsl:if
test="translate((substring(//index/@entry,1,1)),'1234567890@#','')=''">
    <h2>Numbers &amp; symbols</h2>
  </xsl:if>

  <xsl:for-each select="//index[count(. | key('letters',
substring(@entry,1,1))[1]) = 1]">
    <xsl:sort select="@entry" />
    <xsl:variable name="initial" select="substring(@entry,1,1)" />
    <xsl:choose>
      <xsl:when test="translate($initial,'1234567890@#','')=''">

                         <!-- Tried adding something here before, but could
-->
                         <!-- never get something here to not repeat for
-->
                         <!-- each group
-->

        <xsl:for-each select="key('letters', $initial)">
          <xsl:sort select="@entry" />
          <p><a><xsl:attribute name="href"
saxon:disable-output-escaping="yes"><xsl:value-of
select="../@location"/></xsl:attribute><xsl:value-of
select="@entry"/></a></p>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <h2><xsl:value-of select="$initial" /></h2>
        <xsl:for-each select="key('letters', $initial)">
          <xsl:sort select="@entry" />
          <p><a><xsl:attribute name="href"
saxon:disable-output-escaping="yes"><xsl:value-of
select="../@location"/></xsl:attribute><xsl:value-of
select="@entry"/></a></p>
        </xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
</xsl:template>


 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.