Thanks, Mike
conventional solution worked great
-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Sent: Wednesday, March 09, 2005 5:29 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] if condition
Here's one way:
<xsl:template match="customer">
<xsl:attribute name="age">unknown</xsl:attribute>
<xsl:copy-of select="@age"/>
this relies on the fact that if you add two attributes with the same
name to
a result element, the last one wins.
A more conventional solution is
<xsl:choose>
<xsl:when test="@age"><xsl:copy-of select="@age"/></xsl:when>
<xsl:otherwise><xsl:attribute name="age".....
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Bhaskar, Rajan [mailto:RBhaskar(_at_)cvs(_dot_)com]
Sent: 09 March 2005 21:16
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] if condition
Hi,
How can i do a if condition in XSLT when a particular
attribute/element
in xml is not present and else with a default string
<customer name="xy" age="30">
say incase age is not present. i want to replace with "unknown"
<customer name="xy" age="unknown">
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--