Tempore 09:16:52, die Wednesday 02 March 2005 AD, hinc in foro {comp.text.xml} scripsit Zhou Lei <da*********@hotmail.com>:
The XML file contains 2 locations, and each location has different kinds of CDs
available (some are unavailable, for example, classical CDs are absent at
location "Address"). And the correct CDs should appear according to
its location and the category should be listed in ascendent order. Is it
possible to do it? Thank you.
Once again, no problem:)
here's one example, using xpath rather than keys.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:template match="category"/>
<xsl:template match="welcome | headline">
<xsl:element name="h{count(ancestor::*)}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="cdshelf">
<xsl:variable name="shelf" select="."/>
<xsl:for-each select="ancestor::shop/category/cd">
<xsl:sort/>
<xsl:if test="$shelf/disc[@cg=current()/@type]">
<h4><xsl:apply-templates/>:</h4>
<ol>
<xsl:apply-templates select="$shelf/disc[@cg=current()/@type]"/>
</ol>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="location">
<h3>Location <xsl:value-of select="@name"/>:</h3>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="disc">
<li><xsl:value-of select="@name"/></li>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis (
http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Spread the wiki (
http://www.wikipedia.org)