|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Selecting and printing certain nodes
> -----Original Message----- > From: Glenn MacGregor > <snip /> > This all work great. Now my question is can you think of a way to handle > nested foreach statments? > > <foreach param="devices"> > <tr><td colspan="2"><variable/></td></tr> > <foreach param="parameters"> > <tr><td><variable/></td></tr> > </foreach> > </foreach> > Hmm. If you would have a template to match foreach-elements, and you apply-templates without selecting any node in particular, then the processor should do all the rest for you, pushing the descendant::foreach --no matter what depth - through its matching template and treat it the same way as the higher level foreach... So, by adding this <xsl:template match="foreach"> <xsl:apply-templates select="do" /> </xsl:template> the do-template in my example, with a slightly modified variable (otherwise it suffers the same defects as pointed out by David and Wendell --text will not be selected) will ensure that the descending foreach's have a matching template that is of higher priority than the node() template. So, make the variable <xsl:variable name="vdo" select="node()" /> If the do element (or in your altered design: the descendant nodes of the foreach) contain(s) nested foreach elements, this template will treat *their* descendants (the do, or, if you will, 'body' of the foreach) as they are encountered, and will use the other already defined templates to provide you with the correct result. > Do I need to pass a variable which is an array or something So the answer to this one would be: no. Cheers, Andreas XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








