Page 1 of 1

Constraining DITA with xsd

Posted: Wed Aug 03, 2016 5:07 pm
by Patrik
Hi,

I'm trying to create a constraints on DITA - e.g. enforce <title> to be the first element of a section. While this was very simple to do with Relax NG I didn't manage to realize this with XSD.

Even the simple sample I found http://dita4practitioners.github.io/dit ... odule.html does not work since I'm getting a Saxon error:
Saxon-EE 9.6.0.7
fatal
Group p.content is not a valid restriction of the group that it redefines. Restricted type allows element u where the base type does not
I also found this tutorial http://oxygenxml.com/doc/m/dita1.2_spec ... n-xsd.html but it only removes an element. But this is not sufficient to force the title-element to be the firt child of a section!?

Is there any known issue? Or can you maybe point me to any other sample or tutorial?

Thanks and regards,
Patrik

Re: Constraining DITA with xsd

Posted: Thu Aug 04, 2016 7:48 am
by Patrik
Hi again,

I just managed to make it work. It appears that Saxon expects that groups that are extended in an xs:redefine to reference themselves. So the sample needs to look like this to work:

Code: Select all

<xs:schema 
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:redefine schemaLocation="highlightOnlyPConstraintsInt.xsd">
<!-- constrain content of <p> element -->
<xs:group name="p.content">
<xs:choice>
<xs:group ref="p.content"/> <!-- reference original (empty) group to indicate the redefine as extension -->
<xs:group ref="p-highlight-only.content"/>
</xs:choice>
</xs:group>

</xs:redefine>

</xs:schema>
Patrik

Re: Constraining DITA with xsd

Posted: Thu Aug 04, 2016 12:11 pm
by radu_pisoi
Hi,

I think that the XML Schema redefine feature requires to always refer the redefined component.

This requirement is implemented by both XML Schema validators: Saxon and Xerces.

Re: Constraining DITA with xsd

Posted: Fri Aug 05, 2016 9:27 am
by Patrik
I could find the relevant part in the spec and it basically says that when extending a group by xs:redefine indeed a reference to itself is required...

However, I still have a problem with my DITA constraints.

intermediate file 'my_commonTopicsConstraintModInt.xsd':

Code: Select all

[...]
<xs:redefine schemaLocation="urn:oasis:names:tc:dita:xsd:topicMod.xsd:1.3">
<xs:group name="section.content">
<xs:sequence>
<!-- "clear" group content so we can then override it again in the next level of redefine. -->
</xs:sequence>
</xs:group>
</xs:redefine>
[...]
module file 'my_commonTopicsConstraintMod.xsd':

Code: Select all


[...]
<xs:redefine schemaLocation="my_commonTopicsConstraintModInt.xsd">

<xs:group name="section.content">
<xs:sequence>

<xs:group ref="section.content"/> <!-- reference orginal group to mark this redefine as extension. -->

<xs:group ref="title"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="basic.block"/>
<xs:group ref="draft-comment"/>
</xs:choice>

</xs:sequence>
</xs:group>
</xs:redefine>
[...]
My topic schema including this module validates fine with Saxon as well as Xerces. And all the topics as well.

But when validating my DITA map using the DITA Map Manager I get these messages for each topic:
E [Xerces] rcase-Recurse.2: There is not a complete functional mapping between the particles.
E [Xerces] src-redefine.6.2.2: Group 'section.content' does not properly restrict the group it redefines; constraint violated: 'rcase-Recurse.2'.
I'm using oXygen 17.1.

Any ideas?

Thanks and regards,
Patrik

Re: Constraining DITA with xsd

Posted: Mon Aug 08, 2016 5:14 pm
by radu_pisoi
Hi Patrik,

Unfortunately, I don't have to much experience with XML Schema based DITA specialization.

I would suggest that you register and ask around on the Yahoo Groups DITA Users List. This list is monitored by many DITA specialists and consultants and maybe one of them already encountered this problem.