Subject: RE: [xsl] XSL Template Match using z:row attributes From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx Date: Wed, 12 Dec 2001 11:16:31 -0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSL Template Match using z:ro, Mark Nahabedian | Thread | RE: [xsl] XSL Template Match using , Michael McCarty |
RE: [xsl] XPath: all elements with , Gertjan Assies | Date | RE: [xsl] Dumb questions from a new, Steve Renshaw |
Month |