[xquery-talk] Function for determining one XPath as subset of another
Pavel Velikhov
pavel.velikhov at gmail.com
Thu Jan 28 05:17:01 PST 2016
No, the first line in the base case should also return false, sorry
>
>
> So suppose you have 2 path expressions, p1 and p2, and you allow only /x or //x as path steps
> and each path step can have a predicate:
>
> p1 = axis_1 pred_1, …, axis_n pred_n
> p2 = axis_1 pred_1, … , axis_m pred_m
>
> subsumes(p1, p2):
> /* recursion base case */
> if p1 is empty: return true
> if p2 is empty: return false
>
> a_1 = first axis of p1
> a_2 = first axis of p2
>
> if a_1 is a child axis ‘/‘ label l :
> if a_2 is a child axis ‘/' with the same label l, and the predicates are equivalent:
> return subsumes(p1 - a_1, p2 - a_2)
> else:
> return false
>
> if a_1 is a descendants axis ‘//‘ with label l:
> if p2 contains an axis with label l:
> p2’ = remove all axes of p2 from the head, until you find an axis with label l
> p2’ = remove the axis with label l from p2'
> return subsumes( p_1 - a_1, p2’ )
>
> return false
More information about the talk
mailing list