Jeni, Jarno and David
Thanks for the help. (now I need to make sure I fully understand it!)
Bodrul
-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk]
Sent: 03 July 2003 11:01
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] xpath confusion
there are 4 possible answers that a compliant system could give to
XPath: "Root/Keys/Client[(_at_)id="abc"]/ descendant-or-self::node()"
8, 6, 4 or 3
as there there is the Client node itself (as you used descendant-or-self
rather than child) plus 7, 5, 3 or 2 child nodes.
The child nodes are counted as follows:
7: Your XML preserves all white space and comments, and your stylesheet
isn't discarding white space with xsl:strip-space
5: Your XML parser discards comments but white space is preserved
3: your parser keeps comments but the parser or stylesheet are
discarding white space
2; your parser discards comments and teh parser or stylesheet is
dicarding white space.
So it seems that you are discarding white space most likely you have
xsl:strip space somewhere or are using MSXML which takes a cavalier
attitute to (not) preserving space in the input document.
That assumption then explains your remaining queries
XPath: "Root/Keys/Client[(_at_)id="abc"]/ descendant-or-self::comment()"
selects 1 node
you have one child node, here descendant-or-self::comment
is the same as descendant::comment you don't get 1 extra node from the
current Client node, as that isn't a comment.
XPath: "Root/Keys/Client[(_at_)id="abc"]/ descendant-or-self::text()"
selects 0 nodes.
As above on the assumption you've discared the white space, there are no
text node children, and the Client node is an element not text so 0 it
is.
I would like to select the 3 nodes <Client>, <a /> and <b />. Any help is
appreciated.
Root/Keys/Client[(_at_)id="abc"]/descendant-or-self::*
will select Client and its element children and return 3 nodes.
David
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
---------------------------------------------------------------------------
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.
Any views or opinions presented in this Email message are solely those
of the author and do not necessarily represent those of Synergy
Logistics Limited unless specifically stated.
Email communications are not necessarily secure and therefore
Synergy Logistics Limited does not accept legal responsibility for the
contents of this message.
If you are not the intended recipient and have received this message in
error, Please notify Synergy Logistics Limited immediately.
Synergy Logistics Ltd. 01509 232706
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list