This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: breaking sorted material into subsections


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]