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

RE: How do you select all unique first-position charac

Subject: RE: How do you select all unique first-position characters?
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Date: Wed, 20 Nov 2002 17:39:15 -0500
xsl select all
I'm not sure if this what your going for, but the template below can either
retrieve you a text list (see comments) or a nodelist containing the nodes
of the all unique first letters where the assumption is which person node it
is doesn't matter.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
   <report-data>
      <xsl:variable name="slist">
         <xsl:for-each select="//person">
            <xsl:sort data-type="text" order="ascending"
                          case-order="upper-first" select="@name"/>
            <xsl:choose>
               <xsl:when test="position()=1">
                  <xsl:copy-of select="."/>
                  <!--<xsl:value-of select="substring(@name,1,1)"/>-->
               </xsl:when>
               <xsl:when test="position() &lt; last()">
                  <xsl:if test="substring(@name,1,1)
                                !=
                                substring(preceding-sibling::*[1]/@name,1,1)
                             and
                             substring(@name,1,1)
                             !=
                             substring(following-sibling::*[1]/@name,1,1)">
                     <xsl:copy-of select="."/>
                     <!--<xsl:value-of select="substring(@name,1,1)"/>-->
                  </xsl:if>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:if test="substring(@name,1,1)
                                     !=
 
substring(preceding-sibling::*[1]/@name,1,1)">
                     <xsl:copy-of select="."/>
                     <!--<xsl:value-of select="substring(@name,1,1)"/>-->
                  </xsl:if>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:for-each>
      </xsl:variable>
      <xsl:copy-of select="$slist"/>
   </report-data>
</xsl:template>
</xsl:stylesheet>

 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.