Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Advance sorting in XSL

From: "Superpitcher" <benoit.mezandemalartic@----.--->
To: 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



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