<div dir="ltr">Hi Adam,<div><br></div><div>This may sound stupid, but: have you considered that (and would it be relevant to you that) the second expression may raise errors that the first one wouldn't have raised, rather than returning a subset?</div><div><br></div><div>Consider the case where b has a numeric type, and the attribute a cannot be cast to double?</div><div><br></div><div>Kind regards,</div><div>Ghislain</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 28, 2016 at 2:17 PM, Pavel Velikhov <span dir="ltr"><<a href="mailto:pavel.velikhov@gmail.com" target="_blank">pavel.velikhov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">No, the first line in the base case should also return false, sorry<br>
<span class=""><br>
><br>
><br>
> So suppose you have 2 path expressions, p1 and p2, and you allow only /x or //x as path steps<br>
> and each path step can have a predicate:<br>
><br>
> p1 = axis_1 pred_1, …, axis_n pred_n<br>
> p2 = axis_1 pred_1, … , axis_m pred_m<br>
><br>
> subsumes(p1, p2):<br>
>  /* recursion base case */<br>
>  if p1 is empty: return true<br>
>  if p2 is empty: return false<br>
><br>
>  a_1 = first axis of p1<br>
>  a_2 = first axis of p2<br>
><br>
>  if a_1 is a child axis ‘/‘ label l :<br>
>   if a_2 is a child axis ‘/' with the same label l, and the predicates are equivalent:<br>
>      return subsumes(p1 - a_1, p2 - a_2)<br>
>   else:<br>
>      return false<br>
><br>
>   if a_1 is a descendants axis ‘//‘ with label l:<br>
>     if p2 contains an axis with label l:<br>
>        p2’ = remove all axes of p2 from the head, until you find an axis with label l<br>
>        p2’ = remove the axis with label l from p2'<br>
>        return subsumes( p_1 - a_1, p2’ )<br>
><br>
>  return false<br>
<br>
<br>
</span>_______________________________________________<br>
<a href="mailto:talk@x-query.com">talk@x-query.com</a><br>
<a href="http://x-query.com/mailman/listinfo/talk" rel="noreferrer" target="_blank">http://x-query.com/mailman/listinfo/talk</a></blockquote></div><br></div>