This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xpath problem
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] xpath problem
- From: Oliver Becker <obecker at informatik dot hu-berlin dot de>
- Date: Tue, 7 Aug 2001 10:49:55 +0200 (MET DST)
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Spencer,
> <a>
> <b id="new">
> <f>new</f>
> <c id="new">
> <d id="old">hi</d>
> </c>
> </b>
> <b id="new">
> <f>new</f>
> <c id="old">
> <d id="new">hi</d>
> </c>
> </b>
> <b id="old">
> <f>new</f>
> <c id="old">
> <d >new</d>
> </c>
> </b>
> <b id="old">
> <f>old</f>
> <c id="old">
> <d >new</d>
> </c>
>
> </b>
> </a>
>
> for this file i used an expression this way
>
> <xsl:for-each select="a">
There's only one a element.
> <xsl:variable name="mcid"><xsl:value-of select="@mcID"/></xsl:variable>
This has no mcID attribute, so $mcid is empty.
> <xsl:value-of select="count(b[contains(new,text())])"/>
>
> this gives me a correct value
What do you define as "correct"?
0?
4?
something else?
This expressions counts all the b children whose string-value of
the first text child is contained in the string-value of the child
new. Well, in your case that means: is the string "
 " (text())
contained in the empty string (new)? (because b has no children of type new).
This condition is false for all bs, the result should be 0.
Or - different interpretation - you're using msxml, which strips
whitespace-only text nodes, i.e. text() evaluates to the empty string.
In this case the condition is always true, the result should be 4.
> where as the below one does not give the correct value
> <xsl:value-of select="count(c[contains(new,d)])"/>
Well, the result is 0, and this is definitivly correct, because a has
no c children at all. It has c descendants.
> what is wrong in my statement
> sorry for the ignorance cause i am new to xslt stuff
If you could verbally explain what do you want to count then maybe
someone will provide an XPath for you.
Cheers,
Oliver
/-------------------------------------------------------------------\
| ob|do Dipl.Inf. Oliver Becker |
| --+-- E-Mail: obecker@informatik.hu-berlin.de |
| op|qo WWW: http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list