I have a situation where the param won’t be set, but my attempts to capture & handle the sitation aren’t working.
I’m using the following:
<xsl:template match="xs:complexType">
<xsl:param name="prefix" />
<xsl:variable name="prefix-no-core">
<xsl:choose>
<!-- if no value, default to 'AcRec' -->
<xsl:when test="not($prefix)">
<xsl:value-of select="'AcRec'" />
</xsl:when>
<!-- if 'core', leave as empty string -->
<xsl:when test="$prefix = 'core'">
</xsl:when>
<!-- if 'AcRec', set the value -->
<xsl:when test="$prefix = 'AcRec'">
<xsl:value-of select="$prefix" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<xs:complexType name="{concat($prefix-no-core, @name)}">
...
</xsl:template>
I’ve also tried $prefix=” in the first test – neither work. but if I use:
<xsl:value-of select="not($prefix)" />
… the value prints out as true. But using that in my xsl:choose doesn’t produce any output.
Of the suggestions made to date, the only solution that worked was to always set the parameter value when a call to the template is made. For example, previously I had:
This had to be changed to:
I’d really like to know why not($param) and $param=” don’t work in a WHEN test, yet I can get the value of not($param) in a xsl:value-of statement.