// inside a predicate behaves like /descendant:: ???
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 1
- Joined: Wed Jun 17, 2009 12:45 pm
// inside a predicate behaves like /descendant:: ???
Post by schmidlinF »
I this a bug or a feature of xpath?
the following xpath:
on the following XML:
returns 3 nodes instead of just the one.
to get the result I want I need to use
I though was equivalent to but inside a predicate it seems to be equivalent to
Have I missed something?
PS: example kept deliberately simple: please do not tell me I do not need // to get what I want
the following xpath:
Code: Select all
/A/B[//C='want']
Code: Select all
<A>
<B><C>don't want</C></B>
<B><C>want</C></B>
<B><C>don't want</C></B>
</A>
to get the result I want I need to use
Code: Select all
/A/B[descendant::C='want']
Code: Select all
//
Code: Select all
descendant::
, i.e. select descendant nodes of the root element??/descendant::
Have I missed something?
PS: example kept deliberately simple: please do not tell me I do not need // to get what I want
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: // inside a predicate behaves like /descendant:: ???
Post by sorin_ristache »
Hello,
Regards,
Sorin
It is equivalent to /descendant-or-self::node()/ as you can read in the XPath specification:schmidlinF wrote:I thoughwas equivalent toCode: Select all
//
but inside a predicate it seems to be equivalent toCode: Select all
descendant::
, i.e. select descendant nodes of the root element??/descendant::
Have I missed something?
// is short for /descendant-or-self::node()/. For example, //para is short for /descendant-or-self::node()/child::para and so will select any para element in the document
Regards,
Sorin
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service