[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Only output element when parameter value is not eq

Subject: Re: Only output element when parameter value is not equal to blank (or null)
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 01 Feb 2007 13:11:22 +0100
Re:  Only output element when parameter value is not eq
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.