xsl-list
[Top] [All Lists]

RE: [xsl] A more concise way to handle empty numeric elements

2007-06-07 06:29:50
hmmm it's a bit hacky but you can do:

<xsl:variable name="zero">0</xsl:variable>

<xsl:value-of select="(cost1/text()|$zero)[1] + 
(cost2/text()|$zero)[1] + (cost3/text()|$zero)[1]"/>

Unfortunately you can't predict which of (cost2/text()) and $zero will come
first in document order.


hopefully someone else will have a better idea...

Yes, and I missed it: just sum over the non-empty nodes!

Michael Kay
http://www.saxonica.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>
--~--