Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Advance sorting in XSL >Thread Next - Re: Advance sorting in XSL Re: Advance sorting in XSLTo: 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
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
