This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 7933 - Enhancement to doc() to process a set of URIs
Summary: Enhancement to doc() to process a set of URIs
Status: RESOLVED WONTFIX
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-16 08:58 UTC by Michael Kay
Modified: 2009-11-05 17:52 UTC (History)
1 user (show)

See Also:


Attachments

Description Michael Kay 2009-10-16 08:58:31 UTC
Message from Loren Cahlander of Syntactica sent to public-qt-comments on 13 Oct 2009


I would like to request that the specification of fn:doc() be changed to match the implementation of that function by MarkLogic.

In MarkLogic, they deviated from the XQuery spec for the fn:doc() function and it can return multiple documents based on a sequence of document URIs passed into the function at one time.

http://developer.marklogic.com/pubs/4.1/apidocs/SequenceBuiltins.html#fn:doc

The eXist Open Source Database implements fn:doc() to the W3C specification and has the function xmldb:document() that returns multiple documents

Here is the function documentation for xmldb:document() and fn:doc()

xmldb:document() can return multiple documents with a single call and fn:doc() can only return one document at a time.

Another option would be to leave fn:doc() alone and add fn:docs() with the multiple document URIs being passed in.

xmldb

--------------------------------------------------------------------------------

http://exist-db.org/xquery/xmldb
A module for database manipulation functions.
document

--------------------------------------------------------------------------------

xmldb:document($document-uris as xs:string+, ...) node()*
Returns the documents $document-uris in the input sequence. Collection URIs can be specified either as a simple collection path or an XMLDB URI.If the input sequence is empty, the function will load all documents in the database.
$document-uris The document URIs 
  


--------------------------------------------------------------------------------
Returns the documents

--------------------------------------------------------------------------------
Deprecated: See the standard fn:doc() function This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

--------------------------------------------------------------------------------

http://www.w3.org/2005/xpath-functions
A module with the XQuery/XPath Core Library Functions
doc

--------------------------------------------------------------------------------

doc($document-uri as xs:string?) node()?
Returns the document node of $document-uri. Resource URIs can be specified either as a simple collection path, an XMLDB URI or any URI.
$document-uri The document URI 


--------------------------------------------------------------------------------
Returns the document node of $document-uri




Loren Cahlander
Enterprise Architect
Syntactica
Comment 1 Michael Kay 2009-10-16 09:08:14 UTC
Personal response: Generally we made a design decision that functions in the standard function library should not do implicit mapping of sequence-valued arguments. If doc() were to do this, then for consistency we should review the whole function library to see what other functions should do it: for example, root(), base-uri(), etc etc.

It seems to me that it is easy enough to write

//@href/doc(.)

to get all the documents linked from the current document, or to write

for $x in $uris return doc($x)

to process a sequence of strings.

(Personally, I would still like to see a simple mapping operator for atomic values, so that one could write $uris%doc(..) where % is the relevant operator - the difficulty has always been in finding a suitable operator. I would also like to see more functions able to default the first argument to ".", including the ability for user-defined functions to do the same.)

Concerning doc(), it is worth noting that XSLT users have access to the document() function, which does do implicit mapping. That was one of the features that the XQuery WG didn't like, which led to the introduction of doc(). (Other features were the complex rules for determining a base URI). We certainly wouldn't want to complicate life for XSLT users by giving them a choice of three functions with different mixtures of implicit semantics.

Finally, a comment on the proposal. It makes no attempt to say why the new functionality is needed, justifying it solely on the basis that two products have chosen to implement (conformant or non-conformant) extensions that do this. That in itself is not sufficient justification.
Comment 2 Mary Holstege 2009-11-05 17:52:01 UTC
The WG discussed this at the F2F meeting of 2009-11-05, endorsing comment #1.
There are several ways to get the functionality, if it is desirable, including defining your own wrapper function to do it.