Project

Profile

Help

DTDs and doc-vailable()/doc() functions

Added by Anonymous over 14 years ago

Legacy ID: #7591921 Legacy Poster: Mike (odlingsmee)

I am having a small issue using using the document(), doc-available() and doc() functions for an SVG file which contains a DTD declaration. Context: I am trying to check if an SVG file exists on the local file system - using doc-available() - if it is I then load the SVG - using doc() or document() - to ascertain the width, height attributes such that I can create an HTML <embed/> tag with the appropriate width and height attributes. When I first tested this the doc-available() returned false even in circumstances where I knew the file existed. Similarly the doc() and document() functions (I tried both) did not load the SVG XML. To overcome the problem I removed the SVG DTD declaration (hence I have a working work around), but I am just curious as to why the DTD declaration is causing an issue. Now I know these functions only work with "XML" but DTD does not impy it is not XML. Is there some implicit validation that is taking place (which my SVGs are failing) or is it something else entirely? I am using Saxon 8.7 (bit behind the times I know) on Java 1.5 Kind regards, Michael


Replies (3)

Please register to reply

RE: DTDs and doc-vailable()/doc() functions - Added by Anonymous over 14 years ago

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

doc-available() is defined to return true if, and only if, calling doc() would succeed. If anything would cause doc() to fail - for example ill-formed or invalid XML, or a failure to retrieve the DTD, then doc-available() will return false. One difficulty that this causes is that when doc-available() return false, it doesn't tell you why. However, the failure diagnostics from doc() should tell you the reason.

RE: DTDs and doc-vailable()/doc() functions - Added by Anonymous over 14 years ago

Legacy ID: #7592547 Legacy Poster: Mike (odlingsmee)

Thanks - well seeing as I only have to remove the DTD declaration to make this work it would suspect retrieval of the DTD is the issue rather than illformed/invalid XML. Is there a way to prevent Saxon from trying to resolve the DTD - again I have a workaround in place so I am asking mainly out of curiosity. Michael

RE: DTDs and doc-vailable()/doc() functions - Added by Anonymous over 14 years ago

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

It's not Saxon that retrieves the DTD, it's the XML parser. The DTD will always be retrieved (it's necessary because it might contain entity definitions), but you can redirect it to a local copy (or a dummy DTD file) by using OASIS catalogs. There's information on that in the Saxon Wiki on the sourceforge pages.

    (1-3/3)

    Please register to reply