We had a discussion on this subject at the XSL/XQuery WG meetings today. No final decision was made, but I think the general sentiment was to relax the requirement that [doc(document-uri($D)) is $D] must always hold. I'm going to anticipate this decision, which means that for a document returned by collection(), document-uri() will be set to the SystemId found in the Source object returned by the CollationURIResolver, regardless whether it is unique, and regardless of whether a previous call of doc() applied to this URI might have returned a different document.
Michael Kay

From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Steven Grossman
Sent: 22 June 2006 18:18
To: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] fn:document-uri returns empty result when documentisobtained by fn:collection()

thanks for the immediate replies.
the "test" system id was hardcoded for testing purposes.  the idea is to set a URI that can be used to access the document directly using the doc function.
base-uri() does not seem to work even in the case where I use doc():

<xsl:value-of select="document-uri(doc('myScheme:documentName'))"/>
returns - myScheme:documentName, while
<xsl:value-of select="base-uri(doc('myScheme:documentName'))"/>
retuns nothing.

Michael Kay <mike@saxonica.com> wrote:
I've still got a few problems with document-uri(), which are basically caused by problems in the spec. For example, your CollectionURIResolver returns "test" as the systemId of each document in the collection. Does that mean document-uri() should return "test"? If so, it doesn't satisfy the rule in the spec that doc(document-uri($d)) should return $d (unless your URIResolver takes care of this, of course).
I've raised bugs on the spec trying to get this sorted out. I think it's probably better if I make document-uri() return the systemId of such documents, regardless of the above rule, but I'd like to get the rules clarified. Meanwhile, you can use base-uri() which probably gives you what you want.
Michael Kay

From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Steven Grossman
Sent: 22 June 2006 15:56
To: saxon-help@lists.sourceforge.net
Subject: [saxon] fn:document-uri returns empty result when document isobtained by fn:collection()

I have implemented a CollectionURIResolver as follows (based on a message posted to this forum):
public SequenceIterator resolve(String href, String base,
                                    XPathContext context) throws XPathException {
        Document[] documents = ...;  // implementation specific
        StaticQueryContext queryContext =
                new StaticQueryContext(context.getConfiguration());
        List sequenceItems = new ArrayList(documents.length);
        for (int i = 0; i < documents.length; i++) {
            Source source = new DOMSource(documents[i]);
            DocumentInfo documentInfo =
        return new ListIterator(sequenceItems);
It succeeds in returning the appropriate documents but it fails to return anything when passed to document-uri().
My question is - should this work?  I would think I should be able to retrieve the document uri of a document returned from a collection.  Am I missing something? Is this a bug?

Yahoo! Groups gets better. Check out the new email design. Plus there’s much more to come.
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
saxon-help mailing list

Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.