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

RE: Selecting and printing certain nodes

Subject: RE: Selecting and printing certain nodes
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Fri, 20 Feb 2004 18:03:37 +0100
foreach descending
> -----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


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.