Page 1 of 1

Cannot validate with oXygen

Posted: Thu Sep 05, 2013 8:53 pm
by BTullio
Hi,

I am investigating the possibility of moving our department from using XMetal to using oXygen instead.

We have a custom DTD that we are successfully using with XMetaL that is customised for our content.

I was able to take our custom dtd and mod files and move them over to the oXygen folders without any issues.

Well, except one - our <cmd> declaration in the mod will not validate.

Code: Select all

<!ELEMENT cmd ((%image;)+, (#PCDATA | %basic.ph; | %note;)*)>
This syntax is correct according to every DITA resource I can find and XMetaL validates the mod just fine.

The error is

Code: Select all

System ID: C:\Program Files\Oxygen XML Author 15\frameworks\dita\DITA-OT\dtd\technicalContent\dtd\task.mod
Main validation file: W:\Working\2\Procedures\CABCOOL\Cabinet_Cooler_Installation.xml
Schema: C:\Program Files\Oxygen XML Author 15\frameworks\dita\DITA-OT\dtd\base\dtd\task.dtd
Engine name: Xerces
Severity: fatal
Description: A '(' character or an element type is required in the declaration of element type "cmd".
Start location: 240:39
Clicking on the error message shows that it errors out at the "#PCDATA" point of the line.

I can change around the declaration to make it work but not the way we need it to.

We need to have the "image" be required and the elements be optional.

This small detail seems like it might be the only thing holding us back from making the switch to oXygen.

Can anybody help me figure out how to make this work?

Thanks

-Brian

Re: Cannot validate with oXygen

Posted: Fri Sep 06, 2013 9:46 am
by Radu
Hi Brian,

Oxygen uses the Xerces parser to validate the DITA XML documents according to the associated DTDs.
The problem in your case is that #PCDATA | fragment (you want the <cmd> to have mixed content), for example if you remove it from the equation:

Code: Select all

<!ELEMENT cmd ((%image;)+, (%basic.ph; | %note;)*)>
then the DTD becomes valid.
The error given by Xerces is quite ambiguous but I think that it relates to this part of the DTD W3C specification:

http://www.w3.org/TR/REC-xml/#sec-mixed-content
An element type has mixed content when elements of that type may contain character data, optionally interspersed with child elements. In this case, the types of the child elements may be constrained, but not their order or their number of occurrences
So you cannot add #PCDATA in the model of an element when you have a sequence because you cannot impose the order of the elements according to the specs.

Probably XMetal uses another parser which is more lenient with such problems but your DTD as it is right now is not valid according to the specs.

Possible workarounds:

1) Remove the #PCDATA reference and have the tech writers insert a <ph> if they want to enter text after the image.
2) Maybe add an additional required element called <cmdContent>:

Code: Select all

[code]<!ELEMENT cmd ((%image;)+, cmdContent)>
[/code]

which is a sequence of:

Code: Select all

<!ELEMENT cmdContent (#PCDATA | %basic.ph; | %note;)*>
but that would need to be handled in the XSLs as well. And I'm not sure if that would make a valid DITA specialization.
3) Let in the DTDs the image be a choice like all other elements:

Code: Select all

<!ELEMENT cmd (#PCDATA | %image; | %basic.ph; | %note;)*>
but add an additional Schematron constraint to handle the sequencing.
For example by default the DITA document type configuration in Oxygen is configured to validate using DTDs and Schematron rules located in:

OXYGEN_INSTALL_DIR\frameworks\dita\resources\dita-1.2-for-xslt2-mandatory.sch

so if you add an extra pattern there like this:

Code: Select all

<pattern id="checkImageInCms">
<rule context="*[contains(@class, ' task/cmd ')]">
<assert test="count(*[contains(@class, 'topic/image ')]) = 1 and *[1][contains(@class, 'topic/image ')]">
A single image must be the first child of "cmd"
</assert>
</rule>
</pattern>
the automatic validation will signal to the tech writer when he adds too many images or if he forgets to start the cmd with an image.

Regards,
Radu

Re: Cannot validate with oXygen

Posted: Fri Sep 06, 2013 4:53 pm
by BTullio
Great response Radu, thank you.

We will give these a shot and let you know what we can make work.

Re: Cannot validate with oXygen

Posted: Fri Sep 06, 2013 11:20 pm
by BTullio
Option #3 worked wonderfully, thank you.

Re: Cannot validate with oXygen

Posted: Mon Sep 09, 2013 8:30 am
by Radu
Hi Brian,

When a DITA Map is opened in the DITA Maps Manager view and you use the Validate and check for completeness toobar button you can also refer to a Schematron document containing custom business rules which will be checked against each map and topic referenced in the DITA Map project.

Regards,
Radu