I am working on a XSLT that we are using to processes an XML file, and I need to trigger some action if an element is there. Created a Java Extension thinking I could simply set a variable it would evaluate like so:
<xsl:for-each select="//attachments/attachment" xmlns:fbattach="java://com.package.ProcessAttachment">
<xsl:variable name="content"><xsl:value-of select="filedata" /></xsl:variable>
<xsl:variable name="fileName"><xsl:value-of select="name" /></xsl:variable>
<xsl:variable name="fileType"><xsl:value-of select="fileType" /></xsl:variable>
<xsl:variable name="attachmentId"><xsl:value-of select="fbattach:test($fileName, $fileType, $content)" /></xsl:variable>
</xsl:for-each>
The problem I am seeing is that attachmentId
doesn't seem to get evaluated unless I do something like this:
<attatchment2><xsl:value-of select="$attachmentId" /></attatchment2>
It seems that Xalan is lazily-evaluating the variables, only doing the evaluation when it is being used for output. This and this seem to corroborate this theory.
Is there a way to force the evaluation, like a setting or something?
If you want to ensure that an expression is evaluated one way is to use it inside of xsl:message
(https://www.w3.org/TR/xslt-10/#message).