[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 sequence

Maik Stührenberg maik.stuehrenberg at uni-bielefeld.de
Thu Apr 24 15:57:52 PDT 2008


  XQuery and id()/idref(); Controlling the children of
	nodes in the result sequence
Well, if someone of you could be so kind and help me brighten up my mind...

As I only want to output children of a node with a the same value of the 
a:span attribute as the a:span/@xml:id, I tried the following query:

declare namespace a="http://www.example.org/a";
declare namespace b="http://www.example.org/b";
declare namespace c="http://www.example.org/c";
<resultset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://www.example.org/a"
xmlns:a="http://www.example.org/a" xmlns:b="http://www.example.org/b" 
xmlns:c="http://www.example.org/c">
{
let $d := doc('demo_instance.xml')
for $s in $d/a:collection/a:entry/a:spans/a:span
return
   <result span="{$s/@xml:id}" start="{$s/@start}" end="{$s/@end}">
     {
     let $e := $d/a:collection/a:entry/a:data//*[@a:span = $s/@xml:id]
       return
          $e[not(child::element()[@a:span = $s/@xml:id])]
}
   </result>
}
</resultset>

What I don't get is why the c:word elements are still included in the 
output? They don't share the same value with their parent node...

<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:para a:span="seg1"/>
    </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>

Sorry for asking over and over again, but I would really love to solve 
this one -- or get a definite answer that it is not possible in XQuery.

Best regards,

Maik Stührenberg

Michael Kay schrieb:
>> if you rewrote
>>
>> not(ancestor::* intersect $e)
>>
>> to be
>>
>> not(some $x in ancestor::* satisfies $x is $e)
>>
>> ...would that potentially stop searching when it found a 
>> match?  Or would that generate the same code as the top version?
> 
> They're likely to be pretty much equivalent in Saxon.
> 
> .//*[pred]
> 
> will find all the descendant elements and test them against the predicate,
> there are no rewrites that recognize that particular predicates might enable
> the search scope to be reduced, other than the indexing optimisations in
> Saxon-SA which handle predicates such as [relativePath=value].
> 
> Michael Kay
> http://www.saxonica.com/ 
> 
> 

-- 

Maik Stührenberg, M.A.

Universität Bielefeld
Fakultät für Linguistik und Literaturwissenschaft
Universitätsstraße 25
33615 Bielefeld

Telefon: +49 (0)521/106-2534
E-Mail: http://x-query.com/mailman/listinfo/talk

http://www.maik-stuehrenberg.de




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.