I have the following template
<xsl:template match="midas:Request">
<xsl:variable name="var1" select="string(./midas:DataDescriptorGUID/@GUID)"/>
<test>
<result1><xsl:copy-of
select="$OGC_Type[string(midas:DataDescriptorGUID/@GUID) =
@guid]"/></result1>
<result2><xsl:copy-of select="$OGC_Type[$var1 =
@guid]"/></result2>
</test>
</xsl:template>
result2 works fine, and I see the XML fragment, yet result1 is
empty!
Am I missing a trick, result2 should be the same as result1.
Unfortunately in the stylesheet I can't pre-declare the variable
since I want to use it in a key.
Hi,
interesting question :), you're indeed missing a trick.
in this Xpath expression:
<xsl:variable name="var1" select="string(./midas:DataDescriptorGUID/@GUID)"/>
the period (.) selects the context node, which - in this case- is equal to the current node-set of the template (the 'midas:Request' element).
But between the [brackets] in:
<xsl:copy-of select="$OGC_Type[string(midas:DataDescriptorGUID/@GUID) = @guid]"/>
, the context node is changed to the node preceding the left bracket ($OGC_Type). So this expression is trying to access the 'midas:DataDescriptorGUID' child nodes of '$OGC_Type', which do not exist. In other words, you cannot access the current node-set with '.' when you're between brackets. You have to use 'current()' in stead.
use this:
<xsl:copy-of select="$OGC_Type[string(current()/midas:DataDescriptorGUID/@GUID) = @guid]"/>
Hope this helps.
regards,
--
Joris Gillis (
http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum