[thelist] XSL: current node question

Jonathan Chard jonathan at familygenetix.com
Mon Apr 2 10:14:15 CDT 2001


Whoops. Serves me right for not testing first. Of course, the astute amongst
you will have noticed that my suggested solution was ... well.. wrong.

Of course, the real solution is:

<xsl:template match="anne|betty|cindy">
<div>
<xsl:attribute name="class">
<xsl:value-of select="local-name()"/>  <!-- NB. Not select="." -->
</xsl:attribute>
</div>
</xsl:template>

Sorry 'bout that.

<tip type="JavaScript gotchas">
Take care with the with(...) statement, at least in IE. If you create a
temporary variable in your with block that is accidentally the same as an
attribute of the thing that you're 'with-ing', it will overwrite that
attribute of that thing. So if you do

with ( document.forms['myform'] )
{
	var id = myTextField.value; // cache value as using it twice
	doSomethingWith( id );
	doSomethingElseWith( id );
}

The id of the form will be overwritten as a side effect. Not, I suspect,
what you had in mind.

Certainly wasn't what I had in mind!
</tip>





More information about the thelist mailing list