XPath Help Karl Lieberherr
Source of information / Plan / / Complex definition We want to extract the “static” part of XPath Objective: Use / and /+/ (//) to build sequences and use operators: union, intersection and except to combine them.
Mismatches XPath can work without schema. But we want to visualize XPath expression in schema. Works only for “static” XPath expressions XPath views meaning of expression as a sequence. Strategies views the meaning of an expression as a function that maps objects to object graph slices. Traversing slice: sequence of nodes.
Mismatches But we can also view the meaning of a strategy and a class graph as another graph: TraversalGraph
XPath data model In the data model, a value is always a sequence. A sequence is an ordered collection of zero or more items. An item is either an atomic value or a node. singleton, empty sequence. Sequences are never nested.
EBNF for XPath [26] PathExpr ::= ("/" RelativePathExpr?) | ("//" RelativePathExpr) | RelativePathExprPathExpr RelativePathExpr [27] RelativePathExpr ::= StepExpr (("/" | "//") StepExpr)*RelativePathExprStepExpr [28] StepExpr ::= AxisStep | FilterExprStepExprAxisStepFilterExpr
Class dictionaries / EBNF exercise3.txt class dictionaries are both a simplification and extension of EBNF.
EBNF for XPath [30] ForwardStep ::= (ForwardAxis NodeTest) | AbbrevForwardStepForwardStepForwardAxis NodeTestAbbrevForwardStep [31] ForwardAxis ::= | | | | | | | ForwardAxis
EBNF for XPath Combining Node Sequences [14] UnionExpr ::= IntersectExceptExpr ( ("union" | "|") IntersectExceptExpr )*UnionExprIntersectExceptExpr [15] IntersectExceptExpr ::= Instanceof Expr ( ("intersect" | "except") InstanceofExpr )*IntersectExceptExprInstanceof Expr InstanceofExpr [16] InstanceofExpr::= PathExprInstanceofExprPathExpr
sequence operations XPath provides the following operators for combining sequences of nodes: The union and | operators are equivalent. They take two node sequences as operands and return a sequence containing all the nodes that occur in either of the operands. The intersect operator takes two node sequences as operands and returns a sequence containing all the nodes that occur in both operands. The except operator takes two node sequences as operands and returns a sequence containing all the nodes that occur in the first operand but not in the second operand.
sequence operations $seq1 is bound to (A, B) $seq2 is bound to (A, B) $seq3 is bound to (B, C) Then: $seq1 union $seq2 evaluates to the sequence (A, B). $seq2 union $seq3 evaluates to the sequence (A, B, C). $seq1 intersect $seq2 evaluates to the sequence (A, B). $seq2 intersect $seq3 evaluates to the sequence containing B only. $seq1 except $seq2 evaluates to the empty sequence. $seq2 except $seq3 evaluates to the sequence containing A only.
Declare context node type what is meaning of / B and /+/ B?
Mixing strategies and XPath?? what would the meaning be of: –s1 : from A via B to C –s2 : A /+/ D –union (s1 s2)