I think that this will largely depend on the application and/or the
content that you're working with.

You might want to consider using fn:endode-for-uri():
  fn:encode-for-uri("http://foo.bar.baz/doc.xml";)
  ==> http%3A%2F%2Ffoo.bar.baz%2Fdoc.xml

This will help if you consider the case where your source URL contains
query parameters. Encoding the URI will allow you to pass the URI as a
query parameter for document retrieval and/or rendering in your
application.  

For example you could easily provide document retrieval via:
 
http://localhost:9001/get-doc.xqy?uri=http%3A%2F%2Ffoo.bar.baz%2Fdoc.xml

For the use case you mention, your function could check to see if the
document corresponding to the given URL exists in the repository.  It
would then fetch the document via xdmp:http-get() if it does not exist,
otherwise return the document from the repository.

You may also want to think about what happens when the document changes.
Will you keep multiple versions of the document to maintain history (and
adjust your URI scheme accordingly), or will you only keep the "latest"
copy?

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:general-
> [EMAIL PROTECTED] On Behalf Of David Sewell
> Sent: Friday, November 30, 2007 5:15 PM
> To: General XQZone Discussion
> Subject: [MarkLogic Dev General] URI conventions for addressing ML
> Serverdatabase documents?
> 
> Does anyone out there have a URI convention they're using to identify
> documents stored in a MarkLogic database?
> 
> My use case would be a function that can take as an argument either an
> HTTP address or the URI of a document in the MarkLogic database.
> Obviously, as database documents can have URIs that look just like Web
> addresses, I need to distinguish between
> 
>   http://foo.bar.baz/doc.xml  =  Website, use xdmp:http-get()
>   http://foo.bar.baz/doc.xml  =  document in database, use fn:doc()
> 
> I'm figuring we can use a scheme identifier like "ml" and therefore
> identify the second case with the URI
> 
>   ml://http://foo.bar.baz/doc.xml
> 
> but is there a community practice for this sort of thing?
> 
> DS
> 
> --
> David Sewell, Editorial and Technical Manager
> ROTUNDA, The University of Virginia Press
> PO Box 801079, Charlottesville, VA 22904-4318 USA
> Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
> Email: [EMAIL PROTECTED]   Tel: +1 434 924 9973
> Web: http://rotunda.upress.virginia.edu/
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to