RE: Re: [xsl] different first element in a list

Subject: RE: Re: [xsl] different first element in a list
From: cknell@xxxxxxxxxx
Date: Mon, 24 Feb 2003 13:12:17 -0500
> [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="";>
  <xsl:output method="html" indent="yes" encoding="UTF-8" />
  <xsl:strip-space elements="*" />

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

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

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" />

Charles Knell
cknell@xxxxxxxxxx - email

 XSL-List info and archive:

Current Thread