Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - Re: [xsl] Only output element when parameter value is not equal to blank (or null) [Thread Next] Re: [xsl] Only output element when parameter value is not equal to blank (or null)To: Date: 2/1/2007 12:14:00 PM Chris Coyle wrote:
I tried:
<xsl:if
test="exists($productid)">
<Attribute name="PRODUCTID"
type="string"><xsl:value-of
select="$productid"/></Attribute>
</xsl:if>
but got the following error:
06:47:27.062 global (ERROR) - Uncaught Exception:
'exists' is not a valid XSLT or XPath function.
exists() is an XPath 2 function, you use an XPath/XSLT 1 parser. But
even if you weren't, it is not the right thing to do, exists($param)
will always return true(), with one exception, when the variable returns
an empty sequence:
<xsl:param name="myparam" select="()" />
or <xsl:param name="myparam" select="/.." />
then this yields false:
<xsl:if test="exists($myparam)" >....
However, with:
<xsl:param name="myparam" select=" '' " />
or <xsl:param name="myparam" select="0" />
or <xsl:param name="myparam" />
then this yields true:
<xsl:if test="exists($myparam)" >....
Cheers!
-- Abel Braaksma | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
