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

RE: XSL Template Match using z:row attributes

Subject: RE: XSL Template Match using z:row attributes
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Wed, 12 Dec 2001 11:16:31 -0000
xsl match attributes
Michael wrote:

>What I am getting is this:
>
>+ Product 1 
>+ Product 2 
>
>It appears that I get the LEVEL='1', but not the remaining.  I wonder
>if there's a way around 'hard coding' the LEVEL's in case I have more
>than 4 or 5..??  I know it would be easier if my XML was is a different
>format, but I'm forced to use the MS ADO export format.  Thank you, in
>advance, for your help.

Hi Michael,

the problem here is something like this: your input isn't nested, and you
want to nest it according to a LEVEL attribute.
There are three problems with your approach.

1. You're doing the same thing in 5 different templates. Try recursion
instead, then you don't need to worry about how many levels you have. 

2. The location paths in your <xsl:apply-templates>.
 You use paths fine when you select attributes, so I assume you're using the
full path (xml/rs:data/z:row) here because you want to get up out of your
current context (a qualified z:row).
To make your paths work, either use /xml/rs:data/z:row - the "/" will get
you back to the document node, or use ../z:row[@LEVEL=2]- in longhand that's
parent::node()/z:row[@LEVEL=2]. It's just like file directories.

BUT: it still won't work...
3. Matching children with parents.
To get the nesting right you have to put the right children with the right
parents. In your input you have CATEGORYID and PARENTCATEGORYID. A revised
path, still using your approach would be
	"../z:row[(@LEVEL=2) and (@PARENTCATEGORYID =
current()/@CATEGORYID)"
or even 
	"../z:row[(@LEVEL=current()/@LEVEL + 1) and (@PARENTCATEGORYID =
current()/@CATEGORYID)"
You need current() not . because inside a predicate expression . is the node
being evaluated, not the node matched by the current template.

Only recurse...
Tom S-W

 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.