Re: [xsl] Ignoring a DTD with document()

Subject: Re: [xsl] Ignoring a DTD with document()
From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 21 Apr 2024 05:52:09 -0000
Hi Mark,

DTDs are special, compared to other schema languages, in that they allow entity declarations that need to be resolved during parsing. Saxon's -dtd option only controls whether the document be validated against the DTD *after* it has been successfully parsed.

If the document does not use any named character entities, the second-best option is to remove the DOCTYPE declaration altogether. But then you can't have content completion and validation any more for that document.

In Oxygen, where you can find out where the DITA OT ancillary files reside, you can supply a project-specific XML catalog that will resolve any system identifier that ends with 'reference.dtd' to one of the available framework files, such as C:\Program Files\Oxygen XML Editor 26\frameworks\dita\DITA-OT\plugins\org.oasis-open.dita.v1_3\dtd\technicalContent\dtd\reference.dtd

Create a catalog file like this, using systemSuffix and a file URI that points to the framework DTD:

<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <systemSuffix systemIdSuffix="dita-oasis/1.2/technicalContent/dtd/reference.dtd"
    uri="file:///C:/Program%20Files/Oxygen%20XML%20Editor%2026/frameworks/dita/DITA-OT/plugins/org.oasis-open.dita.v1_2/dtd/technicalContent/dtd/reference.dtd"/>
</catalog>

I noticed that the document requests a DITA OT 1.2 DTD so I didn't just map any system identifier that ends with 'reference.dtd' to the 1.3 location given above. Instead I said that if the system id ends with 'dita-oasis/1.2/technicalContent/dtd/reference.dtd' (notice the use of forward slashes despite the backslashes found in the input document), it should resolve to the 1.2 reference.dtd.

If you use Oxygen's .xpr files, store the catalog file in the directory that the .xpr file resides in, for example, locate the 'XML Catalog' entry in the Preferences dialog and add a project-specific entry ${pdu}/mycat.xml that points to the newly created catalog. Of course, if you don't use projects, you can store it anywhere on disk and use the absolute path to the new catalog file as a global option.

Then the following (and your) document should parse (and validate) against the DITA OT 1.2 reference DTD that ships with Oxygen:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE reference PUBLIC "PUBLIC IDENTIFIER" "D:\DocTypes\dita-oasis\1.2\technicalContent\dtd\reference.dtd">
<reference id="d">
  <title></title>
</reference>

HTH,

Gerrit


On 21.04.2024 04:06, Mark Giffin m1879@xxxxxxxxxxxxx wrote:
Thanks Michael,

I'm using Saxon-PE 10.6 from inside Oxygen v24.1. I don't know what XML parser is used in this setup, I assume Xalan. This is the error I get:

I/O error reported by XML parser processing file:/C:/Users/mark/Desktop/company/ExportPub/myfile.xml: D:\DocTypes\dita-oasis\1.2\technicalContent\dtd\reference.dtd (The device is not ready)

I don't have a D: drive and that's probably why there is the "device is not ready" statement. The Saxon command line docs show a "-dtd:(on|off|recover)" option, which makes no difference using any option. I have managed to get around this using other methods, but I have learned that this neck of the woods has a few potholes. Good to know.

Mark


On 4/20/2024 5:41 AM, Michael Kay michaelkay90@xxxxxxxxx wrote:
The answer is, it depends entirely on the XSLT processor you are using. Most XSLT processors are likely to give you access to some kind of resolver mechanism that enables you to control the options used for XML parsing; and at that point it depends on the XML parser you are using.

Michael Kay
Saxonica

On 19 Apr 2024, at 21:45, Mark Giffin m1879@xxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

I'm using XSLT 2.0, trying to open an XML file with document(), the XML file references a DTD that is not available, and document() fails. How can I get document() to ignore the DTD?

Thanks,
Mark

Current Thread