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 9:39:00 AM 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.
Here is my complete set of XML data
<ALL>
<DATA id="1">
<BRAND name="CHANEL"><DATE>01-2005</DATE></BRAND>
<BRAND name="HERMES"><DATE>10-2005</DATE></BRAND>
<BRAND name="REVLON"><DATE>10-2005</DATE></BRAND>
<BRAND name="DIOR"> <DATE>null</DATE></BRAND>
</DATA>
<DATA id="2">
<BRAND name="PEUGEOT"><DATE>10-2004</DATE></BRAND>
<BRAND name="NISSAN"><DATE>null</DATE></BRAND>
<BRAND name="FORD"><DATE>10-2004</DATE></BRAND>
<BRAND name="FIAT"><DATE>10-2005</DATE></BRAND>
<BRAND name="TOYOTA"><DATE>null</DATE></BRAND>
</DATA>
</ALL>
And I'd like have my data displayed DATA set by DATA set i.e. :
DATA SET 1
01-2005
CHANEL
10-2005
HERMES
REVLON
no date
DIOR
DATA SET 2
10-2004
PEUGEOT
FORD
10-2005
FIAT
no date
NISSAN
TOYOTA
As you can see, there are several DATE in common (null, 10-2005) from a
DATA set to the other. What I'd like to do is create an xsl:key for
each DATA set but since the xsl:key tag must be a top-level element, I
don't know how to do that.
Here is the XSL code I use :
<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[generate-id() =
generate-id(key('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="//BRAND[DATE=current()]">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</ul>
</xsl:template>
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
Benoit
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
