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>
Change
<jobInfo>$customer</jobInfo>
to
<jobInfo>
<xsl:value-of select="$customer"/>
</jobInfo>
If text value templates are enabled (using, for example xsl:stylesheet/@expand-text="yes"
), then you could use:
<jobInfo>{$customer}</jobInfo>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With