Page 1 of 1

Associating DTD public identifier with local DTD file

Posted: Mon Aug 14, 2017 11:03 pm
by mboudreau
I'm trying to do something that I think is fairly simple, but I confess I'm confused by some of the vocabulary used in the online documentation.

I'm working with a bunch of files that reference a DTD by its public identifier. E.g.,

Code: Select all

<!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "journalpublishing3.dtd">
I have a local copy of this DTD on my machine at:

Code: Select all

/Users/mrb/Documents/DTDs/journalpublishing-3.0/journalpublishing3.dtd
How do I tell Oxygen to use the local file when it encounters the doctype above?

Re: Associating DTD public identifier with local DTD file

Posted: Tue Aug 15, 2017 9:07 am
by Radu
Hi,

Usually this is done using the XML catalog support in Oxygen:

https://www.oxygenxml.com/doc/versions/ ... alogs.html

You can create an XML catalog file named for example "catalog.xml" with the content:

Code: Select all

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<public publicId="-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" uri="../relative/path/to/journalpublishing3.dtd"/>
</catalog>
and then in the Oxygen Preferences->XML / XML Catalog page add a new reference to your XML catalog, then reopen the XML and validate it.

Usually most sets of DTDs already come with xml catalogs so you may just need to add a reference to the XML catalog located next to your DTDs.

Regards,
Radu

Re: Associating DTD public identifier with local DTD file

Posted: Sat Aug 19, 2017 12:47 am
by mboudreau
Thanks, Radu.

Re: Associating DTD public identifier with local DTD file

Posted: Tue Aug 22, 2017 12:00 am
by mboudreau
So I created a catalog file for just one DTD and added it to the XML Catalog preferences, and everything worked fine.

However, I need to work with two DTDs (input and output), and I'm having problems. I created a catalog file for each DTD, and put the catalog files into the directories containing the DTD files. Now I get validation errors when I'm parsing an instance of the DTD whose catalog file comes second in the XML Catalog preferences list. (For each DTD, I can validate an instance with no errors if that DTD's catalog file is the only one in the preferences list.)

My two DTDs are slightly customized versions of NLM Journal Publishing 3.0 (input) and JATS 1.0.4 (output), which are fairly similar. One important difference is that, while we use the CALS table markup in each (instead of XHTML), we use the 'oasis' namespace prefix only in the JATS 1.0.4 (output) files, and this seems to be at the root of the problem.

How do I ensure that for each DTD, Oxygen consults only the DTD files in the same directory as the main DTD file?

Re: Associating DTD public identifier with local DTD file

Posted: Tue Aug 22, 2017 8:06 am
by Radu
Hi,

From the entire list of specified XML catalogs Oxygen creates a single pool of mappings and after this it will use the XML catalog mappings in the order in which they have been specified to resolve references.
So (at least with the current and previous Oxygen versions) you cannot specify that for a certain validated XML document, only a certain set of XML catalogs should be taken into account.

Regards,
Radu

Re: Associating DTD public identifier with local DTD file

Posted: Tue Aug 22, 2017 7:07 pm
by mboudreau
I have a solution, but I'm not sure if it's ideal.

I set up frameworks for both document types, using only the Public ID for each one in the association rules, specifying the DTD, and adding a catalog file for each one. Tested again, but I was still getting validation errors.

So I compared all the public identifiers in the two DTDs, found the one (related to OASIS tables) that was common to both, and changed it in the .ent file that invoked it and in the catalog file. Now I can have articles in each doctype open simultaneously, and they both validate without errors.

As long as I document this in some README files in various locations, I think I can live with it. But if there's a better solution I'd be grateful for advice.

Re: Associating DTD public identifier with local DTD file

Posted: Wed Aug 23, 2017 7:57 am
by Radu
Hi,

I think you have found the perfect solution for now. You could have also disabled one of the two frameworks if you usually work for long periods of times with only one type of XML. But if you use both types of XML all the time, indeed you need to modify one of the XML catalog mappings and also modify the DTDs from one framework to use a particular mapping in order to stop resolving its reference to a module via another XML catalog.
This is not the first report that the CALS table DTD modules from the JATS framework interfere with other frameworks.
Usually if two catalogs resolve a public ID they should resolve it to the same version of the DTD, so that it would not matter what catalog resolved it first.

Regards,
Radu

Re: Associating DTD public identifier with local DTD file

Posted: Tue Jan 16, 2018 11:44 pm
by mboudreau
I've been working with this solution for a while now, and it seems OK. However, I now need to distribute my two frameworks to other people, so I'd like to give them two folders that they can drop into their own 'frameworks' directories.

The only obstacle is the catalog files I've created. In each one, the <group> elements include an @xml:base attribute that gives an absolute path on my local machine, e.g.,

xml:base="file:///Applications/Oxygen/frameworks/ucp_journalpublishing/dtd/"

Can I use a relative path instead? Does it have to be relative to the frameworks directory, or relative to the directory containing the catalog file, or something else?

Re: Associating DTD public identifier with local DTD file

Posted: Wed Jan 17, 2018 9:34 am
by Radu
Hi,

Yes, you can and you should use relative paths in the "xml:base" attributes or better yet try not use it at all.
For example "xml:base='.'" set in an XML catalog means the current folder where the XML catalog is located. But this is equivalent to having no "xml:base" at all specified anywhere in the XML catalog.

Regards,
Radu

Re: Associating DTD public identifier with local DTD file

Posted: Wed Jan 17, 2018 7:08 pm
by mboudreau
Thanks, Radu. I commented out the <group> tags, and everything works.