Page 1 of 1

Use another DTD?

Posted: Mon Dec 13, 2010 5:07 pm
by anderszvensson
Hi,

I have some DITA documents exported from a CMS, that have CMS-specific attributes added to them. I also have specialized versions of the DITA DTD from this CMS. The documents need to use these specialized versions of the DTD to validate, because of these attributes. DITA OT also needs to use them during processing.

Can I specify that the special DTD versions should be used, both by the editor and by DITA OT during processing, and if so how? Also, it is important that the public ID be used (through a catalog file), because the documents all have user-specific paths in the system ID that is useless on any other computer, and I don't want to have to rely on changing all those paths.

Regards,

Anders

Re: Use another DTD?

Posted: Mon Dec 13, 2010 5:32 pm
by Radu
Hi,

Yes, both DITA OT and Oxygen look in this XML catalog for Public and System ID mappings:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/catalog-dita.xml

So you can add Public ID mappings to your DTDs there.

If Oxygen still has troubles validating the specialized DITA files:
In the Oxygen Preferences->"Document Type Association" page please check the "Enable DTD/XML Schema processing..." checkbox. Then reopen the XML files.

Regards,
Radu

Re: Use another DTD?

Posted: Mon Dec 13, 2010 6:08 pm
by anderszvensson
Thanks. I had actually already tried that, it just turns out there was something wrong with the DTD, so that's why it wasn't validating.

However, even though this works, I really don't want to replace the regular DTD reference in the catalog-dita.xml, because I want to use that one for most DITA files. Is there a way to do this so it only uses the special version if the regular one fails (the next-catalog stuff I guess, I just don't know exactly how to use it)?

Regards,

Anders

Re: Use another DTD?

Posted: Mon Dec 13, 2010 6:20 pm
by Radu
Hi Anders,

A DITA specialization should have other public ID and system IDs than the standard DITA DTDs. In this way you would know if a DITA topic is associated with the specialization and not with the default DTDs.
If this would be the case with your DTDs you would just add additional mappings for your additional public and system IDs.

There is no way to specify through the catalog that if validation fails with an entry mapping, try with another (as you would probably like in this case).

So the bottom line is:
Your used DITA DTDs are not correct DITA DTD specializations, they should have different public and system IDs and be referenced by the DITA topics using those particular public IDs.
or
The CMS should have an export feature which should generate valid DITA topics (in accordance probably with the default DITA DTDs).

Regards,
Radu

Re: Use another DTD?

Posted: Mon Dec 13, 2010 9:42 pm
by anderszvensson
I agree. Unfortunately I have no influence over the specialization and the way it's done, I'm just helping out with the stylesheets for topics that I get sent to me.

Thanks anyway!

Regards,

Anders

Re: Use another DTD?

Posted: Tue Dec 14, 2010 10:47 am
by Radu
Yes, so probably the only way will be to comment and uncomment mappings in the catalog-dita.xml depending on what DITA files you are editing. For Oxygen you can configure additional XML catalogs but catalog-dita.xml is the only catalog file at which DITA OT looks when performing the transformation.

Regards,
Radu

Re: Use another DTD?

Posted: Tue Dec 21, 2010 11:34 am
by anderszvensson
Hi Radu,

Ok, but that's fine if I can only configure additional xml catalogs for Oxygen so that the files can be read by Oxygen, because I'm using a separate dedicated DITA OT for these files, so the DITA OT catalog I can change once and for all and leave it there.

So how do I configure additional ones in Oxygen? Will that mean it will go through them each until it finds a matching DTD as I asked for initially?

Regards,

Anders

Re: Use another DTD?

Posted: Tue Dec 21, 2010 12:32 pm
by Radu
Hi Anders,

The catalog resolver mechanism just iterates through each catalog in the following order:

1) The list of catalogs defined here: Preferences->"XML / XML Catalog" page.

2) The added catalogs for each defined document type from here: Preferences->Document Type Association page.

The first found mapping is considered as correct.

So if you add a custom catalog in the Preferences->"XML / XML Catalog" page place Oxygen will first look in it for mappings instead of looking in the catalog-dita.xml which is added by the DITA document type.
This will mean that content completion, validation will be done using your custom catalog.

Regards,
Radu

Re: Use another DTD?

Posted: Tue Dec 21, 2010 12:44 pm
by anderszvensson
Ok, thanks. But that means that even if I add such custom catalogs, if the mapping has the same "name", and it matches, it will choose that dtd even if it doesn't validate, right? So basically, it doesn't select one of the dtds from a list of catalogs until it finds one that validates, only until it finds one that matches the name?

If so, I guess it makes sense, it just makes my life hard because the topic files I get are f*ed up... :-)

Thanks anyway, please just confirm that I have understood correctly and that I can't really use different dtds with the same mapping name...

Regards,

Anders

Re: Use another DTD?

Posted: Tue Dec 21, 2010 12:47 pm
by Radu
Hi Anders,

Yes, you understood correctly.
There is no functionality for trying to find the first DTD which validates the XML instance. Actually DTDs are created to find validation problems in XML instances :)

Regards,
Radu

Re: Use another DTD?

Posted: Tue Dec 21, 2010 3:13 pm
by anderszvensson
Yes, of course :-). However, I have a follow-up question: I am now trying to do transformations with the alternative DTD. I have configured catalog-dita.xml and also catalog-dita_template.xml to use the alternative DTD. Oxygen is configured to use the same catalog-dita.xml in the DITA OT I use (the catalog files in the default location of that DITA OT). The problem is, the validation works fine now in Oxygen and says the ditamap is valid. But when I run the transformation, the error log says there is an undeclared entity (even though Oxygen clearly stated the file was valid, using the same dtd through the same catalog-dita.xml).

Here's the replacement of the DTD mapping in catalog-dita.xml:

Code: Select all

 <public publicId="-//OASIS//DTD DITA Map//EN" uri="DOCAN/map.dtd"></public>
<!--<public publicId="-//OASIS//DTD DITA Map//EN" uri="map.dtd"></public>-->
And here's the first part of the ditamap:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "file:F:/02_CUSTDOC_USERS/Personer%20som%20slutat/Jenny%20H/Till%20Anders/DOCAN/DIA%20DITAMap/map.dtd">
<!-- Created with XMetaL (http://www.xmetal.com) -->
<map xmlns:dctm="http://www.documentum.com" xml:lang="en-GB"
id="map_38F4A314F62140B4ACDD5907A1078FF8" ditaarch:DITAArchVersion="1.1"
domains="&included-domains;" class="- map/map " title="Test"
dctm:obj_status="Read-Only" dctm:obj_id="0900219e803a3af6" dctm:version_label="CURRENT"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
The public ID has been mapped, and again validation works fine. But why doesn't the transformation approve the file then when the catalog-dita.xml to resolve the dtd is the same?

The error message is:

[pipeline] org.dita.dost.exception.SAXExceptionWrapper: C:\DitaContent\Test.ditamap Line 6:The entity "included-domains" was not declared, but was referenced in the attribute "domains" of the element "map".

I've checked the entity and it should be declared fine, and the fact that Oxygen states that the file is valid should be confirmation of that too... So what's wrong?

Regards,

Anders

Re: Use another DTD?

Posted: Tue Dec 21, 2010 3:27 pm
by Radu
Hi Anders,

The XML file is valid but:
The DITA Open Toolkit is not very good at processing and expanding entity references in the XML files. In fact a couple of versions ago they introduced a speed improvement which introduced this problem of entities no longer being correctly resolved.

In your XML files you have code like:
domains="&included-domains;" class="- map/map "
These attributes usually are not usually included literally in the XML file, they take default values from the associated DTDs and the DITA specification disallows the use of entities.

I will assume you have Oxygen 12. If you are using the DITA OT bundled with Oxygen we made a patch for this problem so there is one thing you should try out: edit the transformation scenario, in the Parameters tab set the disable.grammar.caching to yes.

In more recent versions of the DITA OT they also added a parameter for this called args.grammar.cache which you can add to the Parameters list and set to no.

See the original bug posted at the DITA OT:
https://sourceforge.net/tracker/index.p ... tid=725074

Regards,
Radu

Re: Use another DTD?

Posted: Tue Dec 21, 2010 4:30 pm
by anderszvensson
Thanks, that worked!

Regards,

Anders