|
>Home>Learn XQuery> XQuery Tips and Tricks>Using Collection Functions
Print
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?
|