[oXygen-user] XQuery
Brett Zamir
Tue Oct 30 12:43:12 CDT 2007
Excellent, thanks... and thanks for the tip about document-uri(). Pretty
new to XQuery...
One other question if I may...
I'm trying to get a listing of distinct elements across files in a
directory... and for each distinct value, I'd like to know what one of
the files was from which that distinct value came (or even better, a
concatenated list of file names). But since I only want distinct values,
I don't want to add the filename to the result since it will cause the
value to not be distinct (though I'd like to store information about the
filename).
For example, I'd like to search for all values of <myElement> and get
back something like this as a list of distinct values:
<a>Files: a.xml, q.xml, z.xml: "Value 1"</a>
<a>Files: b.xml, c.xml: "Value 2"</a>
or at least get one of the files in which the value is present to show up:
<a>Files: a.xml: "Value 1"</a>
<a>Files: b.xml: "Value 2"</a>
I've tried the following, but it causes each value to be repeated, since
it iterates over each filename listing as a distinct result:
<result>
{
for $b in distinct-values(
for $a in collection("file:///C:/mypath")
for $c in document-uri(collection("file:///C:/mypath"))
return <a>Files: {$c}: {$a//myElement/string()}</a>
)
return
<b>{$b}</b>
}
</result>
Same result if I try to add $c to the outer level...
thanks,
Brett
Sorin Ristache wrote:
> Yes, use the collection() function implementation from Saxon 8B
> available in oXygen as XQuery engine. See the following topic on the
> oXygen forum:
>
> http://www.oxygenxml.com/forum/ftopic2043.html
>
>
> Regards,
> Sorin
>
>
> Brett Zamir wrote:
>> Is there an easy way to perform an XQuery against all XML files
>> within a given folder?
>>
>> thanks,
>> Brett
>
> _______________________________________________
> oXygen-user mailing list
>
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
>
More information about the oXygen-user
mailing list