|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] XQuery and id()/idref(); Controlling the children of nodes in the result sequenceMaik Stührenberg maik.stuehrenberg at uni-bielefeld.deThu Apr 24 14:57:03 PDT 2008
Michael Kay schrieb: >> So if I am right, you want to not include an element if one >> of its ancestors is included too? If you want so, use the >> following instead of the for: >> >> let $e := $d/a:collection/a:entry/a:data >> // *[@a:span = $s/@xml:id] >> return >> $e[not(ancestor::* = $e)] >> > > That's not quite right, because the "=" tests for equality rather than > identity. > > You could do > > let $e := $d/a:collection/a:entry/a:data > //*[@a:span = $s/@xml:id] > return > $e[not(ancestor::* intersect $e)] Again, thanks for another suggestion, however, the version on top will still result in the output <resultset xmlns:c="http://www.example.org/c" xmlns:b="http://www.example.org/b" xmlns:a="http://www.example.org/a" xmlns="http://www.example.org/a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <result start="0" end="40" span="seg1"> <b:text a:span="seg1"> <b:para a:span="seg1"/> </b:text> </result> <result start="0" end="20" span="seg2"> <c:sentence id="w35" a:span="seg2"> <c:word a:span="to1" id="w36"/> <c:word a:span="to2" id="w37"/> <!-- ... --> </c:sentence> </result> <result start="0" end="4" span="to1"> <c:word a:span="to1" id="w36"/> </result> <result start="5" end="8" span="to2"> <c:word a:span="to2" id="w37"/> </result> </resultset> > > or you could do a recursive function which stops searching any deeper when > it finds a match: > > declare function local:s($e as element(), $id as xs:string) as element()* { > $e/(if (@a:span eq $id) > then . > else */local:s(., $id)) > } > Well, that is the point: the function should not stop searching any deeper when it finds a match -- it should stop searching any deeper when it finds a match and the child element of that match has a different value for the a:span attribute. If I find an element which satisfies @a:span=@xml:id, then I have to look at least one level down further if its child satisfies the condition as well (if not, I'm fine, if it does the same has to be done recursively). Best regards, Maik Stührenberg
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






