I have a xsl as below
<xsl:variable name="foo" select="concat('some','stuff')" />
<xsl:if test="$foo">
<xsl:element name="hello">
<xsl:attribute name="id">
<xsl:value-of select="-1"/>
</xsl:attribute>
<xsl:element name="region">
<xsl:value-of select="$foo/child"/> <!-- foo is variable, but always has a 'child' node -->
</xsl:element>
</xsl:element>
</xsl:if>
I get the below output:
<hello id="-1">
and an exception:
java.lang.ClassCastException: org.apache.xpath.objects.XString incompatible with org.apache.xpath.objects.XNodeSet
what am I doing wrong?
<xsl:value-of select="$foo/child"/>$fooseems to be a string, not a node. But you can only select children from nodes, not from strings.