So I have the following code:
<redirect:write select="concat('..\\folder\\,string(filename),'.xml')">
Where “filename” is a tag in the xml source. My problem occurs when filename is null or blank. And this is the case for several of the xml filename tags. So what I am trying to implement is a checking method. This is what I have done:
<xsl-if test = "filename != ''">
<xsl:variable name = "tempName" select = "filename" />
</xsl-if>
<xsl-if test ="filename = ''">
<xsl:variable name = "tempName" select = "filenameB"/>
</xsl-if>
<redirect:write select="concat('..\\folder\\,string($tempName),'.xml')">
I seem to be getting NPEs when I compile my Java code, saying the Variable not resolvable: tempName
This transformation:
when applied to this XML document:
produces the wanted, correct result:
Do note: Whenever the value of a variable is established based on a condition, this condition is implemented using
<xsl:choose>inside the body of the variable.