XSLT Guid variable bug

2007-11-21 @ 11:14#

ran into a nasty bug in XSLT today. took me a while to sort it out, too.

the following XSLT declaration always resolves to an empty string:

<!-- declare variable -->
<xsl:variable name="guid" select="dc91c9b9-f352-41ca-95da-7af7245ee022" />
<!-- more interesting stuff goes here -->
<span class="guid">
  <xsl:value-of select="$guid" />
</span>

however, this version works just fine:

<!-- declare variable -->
<xsl:variable name="guid" select="'dc91c9b9-f352-41ca-95da-7af7245ee022'" />
<!-- more interesting stuff goes here -->
<span class="guid">
  <xsl:value-of select="$guid" />
</span>

see the diference? i didn't for quite a while. the select="" has the guid value enclosed in single-quotes for the version that works correctly.

sheesh!

update

ahh yes. the node. it turns out the guid i was using is (in this case) a valid NodeName. thus, XSLT attempted to resolve the NodeName instead of just returning the data. guids that start with a letter will always suffer this confusion.

code