From: Michael B. <mbe...@mb...> - 2007-05-22 14:03:05
|
Bryan Rasmussen wrote: > Hi the following xpath returns nothing > > /xs:schema[descendant::xs:complexType[@name]] > Bug! Simple test ========== let $doc := <top> <section> <div2 xml:id="d1"> <p>In div with id d1</p> </div2> <div2> <p>In div with no id</p> </div2> </section> <section> <div2> <p>In div with no id</p> </div2> <div2> <p>In div with no id</p> </div2> </section> </top> return $doc//section[descendant::div2[@xml:id]] ================================ In eXist this returns nothing, in Saxon it correctly returns <?xml version="1.0" encoding="UTF-8"?> <section> <div2 xml:id="d1"> <p>In div with id d1</p> </div2> <div2> <p>In div with no id</p> </div2> </section> ======================================== > I suppose the reason is that the descendant axis only applies to element > content, but it seems to me that the attribute name is not on the > descendant axis by xpath rules. Don't forget that you can change axis at each and every step in an XPath, and within a predicate expression. So just because you start off down the descendant axis doesn't mean you can't turn to look along the attribute axis of whatever node(s) are selected at a given step. Saxon does just that and sees what it ought to. eXist apparently sees nothing, though it certainly should. Michael Beddow |