xsl-list
[Top] [All Lists]

RE: Printing a value if an attribute does not exist

2004-08-24 04:37:13
Try:

<xsl:choose>
 <xsl:when test="REGION [(_at_)NAME='VA']">
    <xsl:value-of select="REGION [(_at_)NAME='VA']"/>
 </xsl:when>
 <xsl:otherwise>0.0</xsl:otherwise>
</xsl:choose>



From: michael(_dot_)s(_dot_)eberhart(_at_)verizon(_dot_)com
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Printing a value if an attribute does not exist
Date: Mon, 23 Aug 2004 23:04:11 -0400





How do you check for the existence of an attribute?

<TIER>
   <REGION NAME="CT">89</REGION>
   <REGION NAME="MD">135</REGION>
</TIER>

What I want to say is:

If region[(_at_)name="VA"] exists
   print value of region[(_at_)name="VA"]
else
   print "0.0"

It is also possible that there will be no REGION elements

<TIER>
</TIER>

I would still want to say:

If region[(_at_)name="VA"] exists
   print value of region[(_at_)name="VA"]
else
   print "0.0"

Thanks

Mike




--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



<Prev in Thread] Current Thread [Next in Thread>