[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xpath problem

Subject: Re: xpath problem
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Aug 2001 10:49:55 +0200 (MET DST)
xpath condition empty string
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 "&#xA;   " (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@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • xpath problem
    • Earl Spencer - Mon, 6 Aug 2001 15:20:54 -0400 (EDT)
      • <Possible follow-ups>
      • Oliver Becker - Tue, 7 Aug 2001 04:53:13 -0400 (EDT) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.