N. America: 800 876 3101 | World: 44 (0) 1753 218 930

Can I use fn:collection() to retrieve the URL of a document in a folder?

Suppose I have this XQuery:

<documents> {
    for $doc in fn:collection("file:///c:/xml?select=*.xml")
    return
        <doument URL="theDocURL">
            {$doc}
        </doument>
} </documents>

How do I assign the proper value to the URL= attribute?

You can assign values to the URL= attribute using the fn:document-uri function, shown here:

<documents> {
    for $doc in fn:collection("file:///c:/xml?select=*.xml")
    return
        <doument URL="{$doc/document-uri($doc)}">
            {$doc}
        </doument>
} </documents>


Next Question!

What's the easiest way to extract the file name from a URL?

Submit Your DataDirect XQuery Tip or Trick

Tell us your XQuery Tip or Trick – if it gets published on our site, you’ll receive a

$10.00 Amazon.com
Gift Certificate!

Submit your tip or trick today.