Bug #2933

Collection function when XML files has a doctype

Added by Pierre Attar over 3 years ago. Updated over 3 years ago.

User error
Start date:
Due date:
% Done:


Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:



I try to user the collection function on an XSLT using saxon :

xsl:message select="count(collection('file:///O:/data/Donnees/trunk/sources/modules/?select=*.ditamap;recurse=no;on-error=ignore'))"/></xsl:message>

This works fine if the file has not doctype declaration.

As soon as there is one,

the function does not works anymore.

A bug ?

Regards, Pierre


#1 Updated by Michael Kay over 3 years ago

When you say it doesn't work, could you explain how it fails?

And when you say it doesn't work "any more", could you say when it did work?

#2 Updated by Pierre Attar over 3 years ago

It does not works means that the file is not found by the "collection" function.

So in the sample, the count function returns 0.

As soon as the doctype is removed in each file, the count function returns the right value (ie the number of *.ditamap files).

Hope this helps, Pierre

#3 Updated by Michael Kay over 3 years ago

If you remove the on-error=ignore, what diagnostics do you get?

(I'm assuming that for some reason the DTD isn't being found, and that on-error=ignore means you get no information about the cause, the file is simply skipped.)

#4 Updated by Pierre Attar over 3 years ago

I've tried all on-error values plus the full removal of the parameter : the same occurs.

You are right, the DTD is not found (but how to provide a catalog ?).

My workaround for now is to put a dtd with a parameter entity going to the location of the "real" dtd.

#5 Updated by Michael Kay over 3 years ago

As far as I can see, to process each file in the collection, Saxon is passing the XMLReader the absolute URI of the document entity in the form of an absolute file:/// URI. If the DTD is referenced by an ordinary relative URI then it should therefore be located correctly.

In comment #4 I'm not sure whether to read this as saying the DTD location "map.dtd" isn't actually the true (relative) location of the DTD file? In that case you would need to use catalogs to find it. There are many ways of customising the lookup behaviour if you want to, but I'm still not clear exactly what your situation is, e.g. where the DTD is actually located.

#6 Updated by Pierre Attar over 3 years ago

OK, now the situation is clear for me :

  • the dtd is defined as a relative path.

  • there is no catalog helping to solve the question to find where is the DTD.

So, if I use saxon in a validation mode, my documents can not be loaded. So there is no bug.

Should I suggest an error message in such a case ?

It should help to debug XSLT stylesheet when there is such a problem.

Regards and thanks for taking time for this issue,


#7 Updated by Michael Kay over 3 years ago

  • Category changed from XSLT conformance to User error
  • Status changed from New to Closed

Thanks, I'm glad we've got to the bottom of this.

I'm afraid the attribute on-error=ignore is an explicit directive to ignore all files that generate errors, so it's hard to see how Saxon can override this and produce any diagnostics. Using on-error=warning would presumably give you some indication of what's wrong.

Please register to edit this issue

Also available in: Atom PDF