Dear XQuery
Experts,
I am new to
XQuery. I am enjoying learning XQuery. I
have made progress but have a long way ahead.
I am using
the web-based tool CQ that ships with MarkLogic server 4.1 and playing
with the sample query to understand XQuery better.
Sample Query:-------------------
xquery
version "1.0-ml";
for $speech
in doc()//SPEECH
let $speaker
:= $speech/SPEAKER
let $lines
:= $speech/LINE
return (
<h1>{$speaker/text()}</h1>,
<p>{for $line in $lines return
$line/text()}</p>
)
=> The
query goes through the entire collection and prints out the name of the speaker
followed by his lines.
Modified Query:
--------------------
xquery
version "1.0-ml";
for $d in
doc()
let $speech
:= $d//SPEECH
let $speaker
:= $speech/SPEAKER
let $lines
:= $speech/LINE
return (
<h1>{document-uri($d)}</h1>,
<h3>{$speaker/text()}</h3>,
<p>{for $line in $lines return
$line/text()}</p>
)
=> I
wanted to print the document name also.
So I started off by making the following change. Here is what I changed ...
and added "document-uri($d)"
to print the name of the document.
Before:
for $speech
in doc()//SPEECH
After:
for $d in
doc()
let $speech
:= $d//SPEECH
=> Is
there anything wrong in doing this?
=> The
query goes through the entire collection.
But here the output is (per document) the list of all speakers (1 long
string of characters) and all their lines concatenated.
I am sure I
can learn something very valuable here.
Thanks for
your time and patience.
Anil
_________________________________________________________________
Bing™ brings you maps, menus, and reviews organized in one place. Try it now.
http://www.bing.com/search?q=restaurants&form=MLOGEN&publ=WLHMTAG&crea=TEXT_MLOGEN_Core_tagline_local_1x1_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general