|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Sorting and navigation
Coppens Benont (All4IT) wrote:
Benoit,
> Table must be sorted first by Author and then by ID
> Next and Previous columns contain the ID of the next/previous
> document
If you can use node-set(), see the David's answer. If you really,
really can't, you can use the solution at the end of the email (but
this is really tricky, it will perform sorting for each next and each
previous!).
BTW I saw a lot of people saying they are using Xalan only because
this is the default processor in the JRE. If this is the case, I would
suggest to have a look at Saxon. This should be easy to plug in your
application instead of Xalan, and give you the power of XSLT 2.0.
<xsl:template match="ALL_DOCUMENTS">
<xsl:text>ID | AUTHOR | NEXT | PREVIOUS </xsl:text>
<xsl:text>----------------------------- </xsl:text>
<xsl:variable name="docs" select="DOCUMENT"/>
<xsl:for-each select="$docs">
<xsl:sort select="AUTHOR"/>
<xsl:sort select="ID"/>
<xsl:variable name="pos" select="position()"/>
<!-- id -->
<xsl:value-of select="format-number(ID, '00')"/>
<xsl:text> | </xsl:text>
<!-- author -->
<xsl:value-of select="AUTHOR"/>
<xsl:text> | </xsl:text>
<!-- next -->
<xsl:choose>
<xsl:when test="$pos = last()">
<xsl:text> *</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$docs">
<xsl:sort select="AUTHOR"/>
<xsl:sort select="ID"/>
<xsl:if test="position() = ($pos + 1)">
<xsl:value-of select="format-number(ID, '00')"/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<xsl:text> | </xsl:text>
<!-- previous -->
<xsl:choose>
<xsl:when test="$pos = 1">
<xsl:text> *</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$docs">
<xsl:sort select="AUTHOR"/>
<xsl:sort select="ID"/>
<xsl:if test="position() = ($pos - 1)">
<xsl:value-of select="format-number(ID, '00')"/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
Regards,
--drkm
_____________________________________________________________________________
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








