See below

On Dec 1, 2010, at 3:28 PM, [email protected] wrote:

> In the XPath spec, it says that "A node test node() is true for any node of 
> any type whatsoever." (http://www.w3.org/TR/xpath/#node-tests).
> 
> So how come the attribute is not included in the following code:
> 
> let $example := <bob time="now">Hello</bob>
> return <results>{$example/node()}</results>
> 
> => <results>Hello</results> 

This is the abbreviated form for $example/child::node(). On the child axis, no 
attributes are selected, so there's nothing for node() to test against.


> 
> 
> but it is included in this code:
> 
> let $example := <bob time="now">Hello</bob>
> return <results>{$example/@*}</results>
> 
> => <results time="now"/> 

This is an abbreviation for $example/attribute::*, which obviously does select 
attribute nodes.

> 
> 
> So to get attributes and all other nodes I'd have to do :
> 
> let $example := <bob time="now">Hello</bob>
> return <results>{$example/(@*|node())}</results>
> 
> => <results time="now">Hello</results>

This is correct.

-m
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to