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

RE: Re: different first element in a list

Subject: RE: Re: different first element in a list
From: cknell@xxxxxxxxxx
Date: Mon, 24 Feb 2003 13:12:17 -0500
select xml element
> [Lorenzo De Tomasi ]
> how can I obtain an ordered list like this
> ...
> Rendering
>
> list:   1
>         2
>         3
>         4
>         5

Your example document has the values in sorted order already, so there is no need to sort them again in the XSLT. This stylesheet will do what you ask:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes" encoding="UTF-8" />
  <xsl:strip-space elements="*" />

  <xsl:template match="/">
    <table>
      <xsl:apply-templates select="xml/element" />
    </table>
  </xsl:template>

  <xsl:template match="xml/element">
    <xsl:choose>
      <xsl:when test="position() = 1">
        <tr><td>list:</td><td><xsl:value-of select="." /></td></tr>
      </xsl:when>
      <xsl:otherwise>
        <tr><td> </td><td><xsl:value-of select="." /></td></tr>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

If the document does not contain the elements in sorted order, you could change this:

<xsl:apply-templates select="xml/element" />

to this:

<xsl:apply-templates select="xml/element">
  <xsl:sort select="." data-type="number" />
</xsl:apply-templates>

-- 
Charles Knell
cknell@xxxxxxxxxx - email


 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.