<xsl:if test="$git-hash eq ''"> ... </xsl:if>
does the trick, at least for me.
I think this is because
<xsl:param name="git-hash"/>
sets $git-hash to the empty string if a value was not supplied. So the point
is that the parameter is defined, but it happens to have nothing as a value.
________________________________
XSLT 2.0, Saxon processor.
What's a good way to check if a variable has a value? I want to print
something if a variable has a value, and not print it if it is not given a
value. This must be extremely simple but I don't see it.
Variable is declared:
<xsl:param name="git-hash"/>
This will sometimes be given a string value like this:
26166cf7f809f5107778c2742e06edb024c5ffef
I tried this and others:
<xsl:if test="matches($git-hash, '\d|[a-z]')">
<dc:subject>git hash: <xsl:value-of select="$git-hash"/></dc:subject>
</xsl:if>
When the variable has no value, the following is output instead of nothing:
git hash: ${git-hash}
The following works but only if the value has numbers in it:
<xsl:if test="matches($git-hash, '\d')">
None of these work, what have I missed:
<xsl:if test="$git-hash">
<xsl:if test="boolean($git-hash)">
<xsl:if test="matches($git-hash, '\d|\S')">
<xsl:if test="matches($git-hash, '\d|[a-z]')">
<xsl:choose>
<xsl:when test="not($git-hash)"></xsl:when>
<xsl:otherwise>
<dc:subject>git hash: <xsl:value-of select="$git-hash"/></dc:subject>
</xsl:otherwise>
</xsl:choose>
EasyUnsubscribe<https://nam12.safelinks.protection.outlook.com/?url=http%3A%2
F%2Flists.mulberrytech.com%2Funsub%2Fxsl-list%2F649132&data=05%7C01%7Cs.bauma
n%40northeastern.edu%7C1f04441596a8433323d008da8aeffd82%7Ca8eec281aaa34daeac9
b9a398b9215e7%7C0%7C0%7C637975060764532619%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC
4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdat
a=3Zejwy7MFasj1ezIk3czVJa6R3mL7jccuWsdB2NXXC4%3D&reserved=0> (by email<>)
|