|
Subject: RE: Sorting revisited (<xsl:sort>) From: r.mcarthur@xxxxxxxxxxxx Date: Tue, 30 Nov 1999 15:07:03 -0500 |
Thanks, I guess my simplification of my source code introduced a lot of
errors. What I actually have (and actually works!) is a document like this:
<doc>
<headers>
<header>....</header>
</headers>
<orderdata>
<variable tags>...</variable tags>
</orderdata>
<orderdata>
...
</orderdata>
... many more <orderdata> ...
</doc>
The portion that does the sorting is this:
<xsl:template match="doc">
<TABLE ... >
<xsl:apply-templates select="child::headers />
<xsl:apply-templates select="child::orderdata >
<xsl:sort select="*[local-name()=string($sortby)]"
data-type="$datatype" order="$orderby" />
</xsl:apply-templates>
</TABLE>
</xsl:template>
The 'select' attribute works fine. Its the data-type="$datatype" and
order="$orderby" which don't work. They are supposed to be attribute value
lists, and I guess I just don't get the syntax.
Rob McArthur
-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Tuesday, November 30, 1999 1:58 PM
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Re: Sorting revisited (<xsl:sort>)
I'll try again:-)
You haven't said what your input document looks like, but I'd guess
that it doesn't match the paths in your select expression.
<xsl:template match="/">
<!-- snip -->
<xsl:apply-templates>
so this apply templates applies to children of the root node.
There must be exactly one such child, and so xsl:sort has only got
a list of length one to sort.
You probably want to use
<xsl:template match="xxx">
where xxx is your document element.
If you do that then
the apply templates applies to all the children of the document node.
<xsl:sort select="*[local-name()=string($sortby)]"
is executed with those children being the current node, this the top
level sortby parameter should name a grandchild of the root, otherwise
the sort key will be null all the time.
If you want to use a sort key that returns a non null value for
the elements named by $sortby you might want ti use
<xsl:sort select="self::*[local-name()=string($sortby)]"
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Sorting revisited (<xsl:sort>), David Carlisle | Thread | horizontal tabs and parsing strings, Earl Bingham |
| Re: axis question, David Carlisle | Date | Re: horizontal tabs and parsing str, Earl Bingham |
| Month |