Abel Braaksma wrote:
Richard Sayre wrote:
I am trying to check me XML to see if any of the descendants contain a
certian value.
<snip />
I can have unlimited Child Types in each type. When I get to a
certain type, I want to check and see if this node or any descendants
of this node has a value of 0 for the inUse node.
This is what I tried but it did not work:
<xsl:if test="descendant-or-self::inUse = 0">
Change it to the following and you should be fine (you are looking for
string, not for a number):
<xsl:if test="descendant-or-self::inUse = '0'" >
Sorry, my mistake. This should not change anything. In XSLT 1.0 what you
specify is correct. In XSLT 2.0, you will receive an error when any node
cannot be converted to an number.
In which case we'll need to know the context. How does your stylesheet
look like? If you try any of my other examples, these all should work
(including using '0' instead of 0).
Two things that can easily make your match fail: a context node that
does not have a child equal to your test pattern, or if you test for a
string, then preserved whitespace may meddle with your results (i.e.,
<xsl:preserve-space elements="*" /> or xml:space="preserve" on the
element). To test if this is the case, change your test to:
<xsl:if test="//inUse[normalize-space(.) = '0']">
If that doesn't match when you place it in your root match (i.e, where
you match '*' or '/') then there really is no inUse with '0' in your
source (the above works regardless of XSLT version 1.0 or 2.0 and
regardless of context) ;)
Cheers,
-- Abel Braaksma
--~------------------------------------------------------------------
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>
--~--