This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Creating a tree variable and using it in later processing
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Creating a tree variable and using it in later processing
- From: Alan Alda <alan4077alda at yahoo dot com>
- Date: Thu, 19 Jul 2001 17:44:07 -0700 (PDT)
- Reply-To: xsl-list at lists dot mulberrytech dot com
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