简体   繁体   中英

What is the meaning of the following XPath fragment?

Im am reading the specifications/documentation of a project and it says:

You may focus on the following XPath fragment: p::= A | * | p/p | p//p | p[q]

What is the meaning of p :: = A ?

I think what it is getting at is specifying a subset of XPath is supported in this context.

p ::= ...

is BNF to say p is defined by the following grammar.

I assume A and q are defined similarly, although you haven't given the context. I'm guessing A is an element name, and q is a boolean expression (however that is defined).

It's mearly saying that the subset of XPath supported is the following:

  • The name of an element ( A )
  • *
  • Two expressions joined with the / operator ( p/p )
  • Two expressions joined with the // operator ( p//p )
  • An expression with a supported predicate ( p[q] )

The provided expression :

A | * | p/p | p//p | p[q]

is the union of the nodes selected by the individual sub-expressions.

It selects any child element named A plus any child elements plus any p element that is a child of a p element that is a child of the current (initial context) node, plus any p element that is a descendant of a p element that is a child of the current node, plus any p child (of the current node) that has a q child.

It is equivalent to the shorter :

 * | p//p

The specific question asked :

What is the meaning of p :: = A ?

The XPath expression

A

selects all children-elements of the current node that are named A .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM