I’ve worked with XSLT variables before, but for some reason, I can not get the stylesheet to see an assigned variable. When I copy sample code it seems to work, so it has to be something I’m doing wrong. Below is the code.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/JDF">
<xsl:variable name="customer"
select="/JDF/ResourcePool[1]/CustomerInfo[1]/@CustomerID"/>
<job>
<jobInfo>$customer</jobInfo>
</job>
</xsl:template>
</xsl:stylesheet>
When I run the above the result is this.
<?xml version="1.0" encoding="UTF-8"?>
<job>
<jobInfo>$customer</jobInfo>
</job>
2
Answers
XSLT 1.0, 2.0
Change
to
XSLT 3.0+
If text value templates are enabled (using, for example
xsl:stylesheet/@expand-text="yes"
), then you could use:Change
to