Project

Profile

Help

collection() function .NET API

Added by Anonymous over 16 years ago

Legacy ID: #5287679 Legacy Poster: Max Toro (maxtoroq)

Hello Michael, I tried to use the collection() function to get all documents in a directory but it throws this error: (err:FODC0004) Unknown collection file:/C:/VSProjects/SaxonAsp/SampleWebsite/App_Data/posts/ URI: file:///C:/VSProjects/SaxonAsp/SampleWebsite/admin/post_list.axt Line number: 6 This is line 6: <xsl:variable name="posts" select="collection('../App_Data/posts/')"/> I've used the collection() function before via command line without problems. I hope I'm not missing something too obvious.


Replies (3)

Please register to reply

RE: collection() function .NET API - Added by Anonymous over 16 years ago

Legacy ID: #5288315 Legacy Poster: Michael Kay (mhkay)

If it works from the command line but not from the API, then the most likely explanation is that you are getting the base URI of the stylesheet module wrong. Is the directory named in the error message file:/C:/VSProjects/SaxonAsp/SampleWebsite/App_Data/posts/ the directory you actually want? I think the most likely cause is that you are processing the stylesheet without giving Saxon its base URI; without that, relative URIs such as ../App_Data/posts cannot be resolved.

RE: collection() function .NET API - Added by Anonymous over 16 years ago

Legacy ID: #5289892 Legacy Poster: Max Toro (maxtoroq)

The directory URI is fine, tested on windows explorer. The XsltCompiler.BaseUri is set to the stylesheet URI. Ran the stylesheet via command line without problems. Maybe is not a problem with the base uri, because it's resolving fine. Also, I can use the doc() function fine. I've tried with the following Saxon-B versions: 9.0.0.6, 9.1.0.1

RE: collection() function .NET API - Added by Anonymous over 16 years ago

Legacy ID: #5298791 Legacy Poster: Michael Kay (mhkay)

It seems that when using the .NET API, the CollectionURIResolver in use is always the DotNetCollectionURIResolver, and this cannot easily be changed (but see below). This will only resolve a collection URI if the URI has been registered using Processor.RegisterCollection(). I think the reason this mechanism was introduced was to satisfy the requirement in the spec that when you retrieve a document using collection(), then get its URI using document-uri(), then use that as an argument to doc(), you get the same document back. This can only be made to work if URIs returned by the collection URI resolver are dereferenced using the same XmlResolver as is used for the doc() function. But clearly this is not very friendly, and it's clearly inappropriate that it should be possible to process a directory by name when using the command line, but not when using the API. I think that to fix this, I will change the DotNetCollectionURIResolver so that if the URI has not been registered, the code falls back to handle it using the (Java) StandardCollectionURIResolver, which handles URIs that refer to a directory. I won't be able to fix this instantly, however. In the meantime, it might be possible to work around it by getting the Processor to use the Java collection URI resolver instead. Try this: processor.setProperty( "http://saxon.sf.net/feature/collection-uri-resolver-class", "net.sf.saxon.functions.StandardCollectionURIResolver") If you do this, RegisterCollection() will not work. Michael Kay

    (1-3/3)

    Please register to reply