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

Creating a tree variable and using it in later process

Subject: Creating a tree variable and using it in later processing
From: Alan Alda <alan4077alda@xxxxxxxxx>
Date: Thu, 19 Jul 2001 17:44:07 -0700 (PDT)
creating a tree xml
Hi,

I have an input XML file in which the elements are not
sorted how I want. I need to 

1. sort the elements and
2. display these sorted elements in a particular
order.

For example my XML file is:

<sw-product-group>
	<product-group-name>Cars</product-group-name>
	<product-group-list number="5">
		<product>
			<name>Buick</name>
			<number>T12340</number>
		</product>
		<product>
			<name>Eagle</name>
			<number>T12335</number>
		</product>
		<product>
			<name>Chevy</name>
			<number>T12340</number>
		</product>
		<product>
			<name>Dodge</name>
			<number>T12345</number>
		</product>
		<product>
			<name>Acura</name>
			<number>T22345</number>
		</product>
	</product-group-list>
</sw-product-group>

As you can see, the input XML document comes to me
sorted by <number> and not by <name> (how the document
is sorted is not in my control :-( ). However, I need
to have my input sorted by <name> and I need to access
the sorted elements according to a certain predefined
order -for the sake of simplicity, lets say I need to
access alternate names in the sorted list.

Here the logic I am currently using:
(I am relatively new to XSL -my disclaimer- and heres
what I am trying to do)
1. Sort the <product> nodes by <name>
2. Store the sorted list in a variable called "tree"
3. Now access $tree, in order to pick out the <name>
nodes in whatever order I please.

The problem, as most of you must have guessed is that
I get an error "Reference to variable or parameter
tree must evaluate to a node list". The XSLT processor
I must use is Xalan - hence, the XSL version 1.0 W3C
recommendation. I have read about similar problems in
an XSL FAQ, but my case seems too simple not to have a
solution.

So my questions are:
How can I solve this problem without using any
extension functions like node-set() etc.? Is there any
logic other than the one I am considering that can
achieve the same effect?

Thanks,
Cheers,
Alan.

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

 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.