Syntax of Location Paths
Location paths supported by the operations that set and get application data are a very limited declarative1 subset of XPath location paths. They must adhere to the following grammar:
Synopsis
| Rule | Operator | Expression |
|---|---|---|
| LocationPath | ::= | ElementTest ( '/' ElementTest )* ( '/' AttributeTest )? |
| ElementTest | ::= | NCName Predicate? |
| AttributeTest | ::= | AttributeRef |
| Predicate | ::= | '[' PredicateExpr ']' |
| PredicateExpr | ::= | AndExpr |
| AndExpr | ::= | EqualityExpr ( 'and' EqualityExpr )* |
| EqualityExpr | ::= | FunctionCall |
| | | AttributeRef '=' PrimaryExpr | |
| FunctionCall | ::= | 'not' '(' AttributeRef ')' |
| AttributeRef | ::= | '@' NCName |
| PrimaryExpr | ::= | Literal |
| | | Number | |
| NCName | ::= | NCNameStartChar NCNameChar* |
| NCNameStartChar | ::= | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] |
| NCNameChar | ::= | NameStartChar |
| | | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] | |
| Literal | ::= | '"' [^"']* '"' |
| | | ''' [^']* ''' | |
| Number | ::= | [+-]? Digits ( '.' Digits? )? |
| | | [+-]? '.' Digits | |
| Digits | ::= | [0-9]+ |
Whithin literals, the delimiting character (QUOTATION MARK or APOSTROPHE) and AMPERSAND (&) must be represented by character references. The value of a numeric character reference must represent the code point of a valid XML character.
Synopsis
| Rule | Operator | Expression |
|---|---|---|
| CharacterReference | ::= | NumericCharacterReference |
| | | '&' | '"' | ''' | '<' | '>' | |
| NumericCharacterReference | ::= | '&' [0-9]+ ';' |
| | | '&x' [0-9A-Fa-f]+ ';' | |
| XMLCharacter | ::= | #09 | #0A | #0D | [#0020-#D7FF] | [#E000-#FFFD] |
| | | [#10000-#10FFFF] |
White space (SPACE, CHARACTER TABULATION, LINE FEED and CARRIAGE RETURN) is allowed between individual grammar symbols except within the productions of NCName, Literal, Number and NumericCharacterReference.
Synopsis
| Rule | Operator | Expression |
|---|---|---|
| WhiteSpace | ::= | #x20 | #x09 | #x0A | #x0D |
Footnotes
-
Location paths used by the operations that set and get application data are declarative because each step of the location path can not only be used to match against existing nodes, but must also declare how to insert a new node if no match is found (operations that set application data must be able to create nodes). In XPath, a relative location path consisting of a single step may look like
Foo[@bar!='abc']. If this syntax would be supported by operations that set application data, and the application data does not contain a matching node, the operation would have to create a new node, but would not know which value to use for the attribute'bar', or whether to add this attribute at all. On the other hand, if the location path isFoo[@bar='abc' and not(@baz)], and the operation does not find a matching node, it knows to create an element named<Foo>with an attribute'bar'whose value is'abc'and without an attribute'baz'. ↩