[Home] [By Thread] [By Date] [Recent Entries]

Subject: RE: Three questions on sorting..
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 20 Jun 2001 11:37:54 +0100

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Tim
> Sent: 20 June 2001 10:58
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Three questions on sorting..
>
>
> Hi,
>
> XML/XSL is below.  These problems are causing a very red forehead
> (since I keep banging it on the table in confusion!)
>
> 1. Why does the <xsl:sort/> cause a "tr is not allowed in
> this position
> in the stylesheet" error?  If I take the sorting tags out, it
> is quite
> happy.

The xsl:sort element should be empty, and should precede the <tr> element.
>
> 2. Can the <xsl:sort/> use a variable directly?  e.g. <xsl:sort
> select="$orderBy"><xsl:sort>  I'll try it myself when I can get the
> answer to question 1!

This is a FAQ. The value of $orderBy doesn't depend on the current node, so
you'll get the same sort key value for every node. You probably want
select="*[name()=$orderBy]".
>
> 3. I would like to sort by manufacturer name but it is in an external
> file.  Is there a way of ordering by the <name/> of the
> manufacture?  I
> can order by the manufacturer ID but not the external name.

You can do something like

<xsl:sort select="document('manufacturers.xml')/manufacturer[id=$id]/name"/>

Mike Kay
Software AG


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Three questions on sorting..
    • Tim - Wed, 20 Jun 2001 05:55:08 -0400 (EDT)
      • Chris Bayes - Wed, 20 Jun 2001 06:12:46 -0400 (EDT)
      • David Carlisle - Wed, 20 Jun 2001 06:23:33 -0400 (EDT)
      • Michael Kay - Wed, 20 Jun 2001 06:31:32 -0400 (EDT) <=
      • <Possible follow-ups>
      • Tim - Wed, 20 Jun 2001 07:06:26 -0400 (EDT)
      • Tim - Wed, 20 Jun 2001 11:08:20 -0400 (EDT)
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member