[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Three questions on sorting..

Subject: RE: Three questions on sorting..
From: "Tim" <xsl@xxxxxxxxxxxxxx>
Date: 20 Jun 2001 15:11:11 -0000
external sorting firstname
Nope.  I did not want to disturb you guys again but 3 after three hours 
of trying, I've run out of aspirin.....

Got sorting by a varibale going, easy with Mike's example.  I've had a 
good look throught the FAQ's again but nothing similar to the sort by 
external elements.  I copied Mike's other example and changed it a bit:

......snip......
<xsl:variable name="manExt" select="document('manufacturers.xml')"/>
..................
<xsl:when test="$orderBy='manufacturer'">
	<xsl:for-each select="car">	
	<xsl:variable name="manId"><xsl:value-of select="normalize-space
(manufacturer)"/></xsl:variable>
	<xsl:sort select="$manExt/manufacturers/manufacturer
[@ID=$manId]/name"/>
		<tr>
			<td>
				<xsl:value-of 
select="$manExt/manufacturers/manufacturer[@ID=$manId]/name/text()"/>
			</td>
			<td>
				<xsl:value-of select="normalize-space
(model)"/>
			</td>
			<td>
				£<xsl:value-of select="normalize-space
(price)"/>
			</td>
	</tr>
	</xsl:for-each>
</xsl:when>
.......snip........

The xsl:value-of for the external manufacturer name works OK but the 
sorting does not sort.

Any more ideas would be lovely.

Thanks again,
Tim.


> 
> 
> > -----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
> 
> 
> 



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.