Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Advance sorting in XSL

From: "Joris Gillis" <roac@-------.-->
To: NULL
Date: 1/10/2005 6:10:00 PM
Tempore 18:38:57, die Monday 10 January 2005 AD, hinc in foro {microsoft.public.xsl} scripsit Superpitcher <benoit.mezandemalartic@n...>:

> Thank you very much. It works very well as long as I have a single set
> of data. Unfortunately, I have several and I'm encoutering a few
> problems.
> and I have 2 problems
> - dates that are both in the DATA set 1 and DATA set 2 are only
> displayed once (that's why I'd like to create a key for each DATA set)
> - BRAND tags from DATA set 2 appear in the DATA set 1 section (due to
> the <xsl:apply-templates select="//BRAND[DATE=current()]"> instruction
> I guess but I don't know what to replace it with)
> Would you have an idea ?
> Thanks a lot in advance

The following stylesheet uses another algorithm to check uniqueness (not 'key()' or 'generate-id()') and will do the task you want:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="ALL">
<xsl:apply-templates select="DATA"/>
</xsl:template>

<xsl:template match="DATA">
<h1>Data Set <xsl:value-of select="@id"/></h1>
<xsl:apply-templates select="BRAND/DATE[not(.=../preceding-sibling::BRAND/DATE)]">
<xsl:sort select="substring-after(.,'-')"/>
<xsl:sort select="substring-before(.,'-')" />
</xsl:apply-templates>
</xsl:template>

<xsl:template match="DATE">
<h2><xsl:value-of select="."/></h2>
<ul>
<xsl:apply-templates select="ancestor::DATA/BRAND[DATE=current()]">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</ul>
</xsl:template>

<xsl:template match="BRAND">
<li><xsl:value-of select="@name"/></li>
</xsl:template>

</xsl:stylesheet>


Note that the XSLT processing time will likely be larger than with the 'key' approach.


regards,
-- 
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Vincit omnia simplicitas
Keep it simple


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent