Lists Home |
Date Index |
Binh Thang wrote:
> I don't receive the error message anymore but still it doesn't sort.
> Below I copied a piece of my xml file. I would like to sort on name of
> the restaurant. Can you pls. help?
> <xsl:template match="/">
> <body [snip]>
> <h2>My Restaurants Guide</h2>
> <xsl:apply-templates />
> <xsl:template match="restaurant">
> <xsl:sort select="name"/>
> <xsl:template match="name">
I miss the XML.
You seem to be under the impression the xsl:sort instruction
should appear in the template which matches the element you
want to sort. THis is not the case, the xsl:sort must appear
in the xsl:apply-templates (or xsl:foreach) which selects the
list of elements you want to sort.
If your source XML is like
then try this
<h2>My Restaurants Guide</h2>
BTW questions regarding XSL are best asked on the XSL list:
THere's also a FFAQ reachable from the page above which has
lots of sample code, some of which is relevant for your question.