xsl-list
[Top] [All Lists]

RE: How to find parent's-parent's-sibling-sibling name

2002-09-19 07:06:50
You could use variable:
<xsl:variable name="FOO">
   <xsl:value-of select="BehaviourInfo/Trap/Name"/>
</xsl:variable>


An xsl:variable that contains a single xsl:value-of is almost always bad
coding. Use

<xsl:variable name="FOO" select="string(BehaviourInfo/Trap/Name)"/>

Apart from the fact that it's one line of code instead of three, it also
defines the variable as a string rather than as a tree. The only useful
thing you can do with this kind of tree in practice is to convert it to
a string, so it's much simpler and more efficient to create it as a
string in the first place.

I thought it worth mentioning because I'm seeing more and more examples
of this bad coding style.

Of course,

<xsl:variable name="FOO">
   <xsl:copy-of select="BehaviourInfo/Trap/Name"/>
</xsl:variable>

is even worse, and also very common.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>