xsl-list
[Top] [All Lists]

Re: xsl:for - Only for existing nodes, how?

2006-02-21 10:37:11

 This was just an example and my real xml 
file goes much deeper after "control". 

if the expressions in the test are more complex it may help  to stick
them in a variable.

<xsl:for-each select="/tree/controls/control">
<xsl:variable name="i1" select="ho/hum/ha"/>
<xsl:variable name="i2" select="fee/fi/fo/fum"/>
<xsl:if test="$i1 and $i2">
   <xsl:value-of select="$i1"/>
   <xsl:value-of select="$i2"/>
</xsl:if>
</xsl:for-each>

that way you don't have to repeat the expression both in the test and
the value of. On the other hand it may make no difference as your xslt
engine may spot repeated sub-expressions and effectively make them into
implicit internal variables anyway.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--