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
http://www.saxonica.com/


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]);
            source.setSystemId("test");
           
            DocumentInfo documentInfo =
                    queryContext.buildDocument(source);
            sequenceItems.add(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?
 
Thanks,
Steven


Yahoo! Groups gets better. Check out the new email design. Plus there’s much more to come.