Hi Anil,
Another quick observation here: Your queries all return the entire database
and process the whole database in a single query. You might want to do this
one play at a time (or even one act or scene at a time). As it is, you end up
sending a huge result back to the browser. So perhaps instead of:
for $speech in doc()//SPEECH
you can do something like:
for $speech in fn:doc("/shakespeare/plays/as_you.xml")//SPEECH
return ....
-Danny
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Florent Georges
Sent: Wednesday, September 23, 2009 11:40 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] FLWOR clarification ...
Anil Shekhar wrote:
Hi,
> for $speech in doc()//SPEECH
> let $speaker := $speech/SPEAKER
Here, you loop over each speech. For each one of them, you bind
the variable $speech to it, and then evaluate the loop body.
Within which you bind the variable $speaker, etc.
> for $d in doc()
> let $speech := $d//SPEECH
> let $speaker := $speech/SPEAKER
Here, you loop over document nodes. For each of them, you bind
all its speeches at once to the variable $speech. So $speaker in
turn is bound to the speakers of every speeches in this document.
And by <h3>{ $speaker/text() }</h3> you create an element the
content of which is the concatenation of all the text node children
of all the speaker elements.
This is a good example where declaring the type (an arity) of
the variables would have helped you:
for $d in doc()
let $speech as element(SPEECH) := $d//SPEECH
let $speaker as element(SPEAKER) := $speech/SPEAKER
Hope that helps (by the way, upper case element names look kind
of weird,) regards,
--
Florent Georges
http://www.fgeorges.org/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general