OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] Quick question regarding XPath

[ Lists Home | Date Index | Thread Index ]

At 2004-02-25 06:04 -0800, Murali Mani wrote:
>You are misinterpreting my question:
>Is it possible to say doc ("test.xml")/a//@b

Yes, that is valid XPath syntax.

>is the above equivalent to:
>doc ("test.xml")/(a/@b | a//*/@b)

If the above were valid XPath 1.0 syntax, then yes.  In XPath 1.0 terms it 
would be: 'doc("test.xml")/a/@b | doc("test.xml")/a//*/@b'

>// is the descendant axis - not the root of the document.

Not quite true and your questions are answered when you realize that "//" 
is an abbreviation of "/descendent-or-self::node()/" ... note how it does 
include itself.  And also note that you cannot end an expression with "//".

So "//" of "//@b" includes the current node, so the current node's b 
attribute is addressed, and it includes its children and descendent 
elements, so their b attributes are also included.

>the question tries to see whether attributes and elements are treated
>similarly by the // axis

The question is not well phrased.  Since "//" is *not* an axis, the 
question would be (I think) "does the // abbreviation give me access to all 
descendent nodes and myself so that when I step away from those nodes in 
the next location step of the location path I can hit both element and 
attribute children I get all attached attributes and child elements and all 
their attributes?" and the answer is yes.

I hope this helps.

...................... Ken

Public courses: Spring 2004 world tour of hands-on XSL instruction
Each week:   Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
United States: Washington, DC March 15; San Francisco, CA March 22
Finland April 26; Hong Kong May 17; Germany May 24; London June 07
World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/x/bc


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS