Constraining DITA with xsd

Patrik
Posts: 240
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Constraining DITA with xsd

Post by Patrik » Wed Aug 03, 2016 5:07 pm

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

Patrik
Posts: 240
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Constraining DITA with xsd

Post by Patrik » Thu Aug 04, 2016 7:48 am

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

radu_pisoi
Posts: 375
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Constraining DITA with xsd

Post by radu_pisoi » Thu Aug 04, 2016 12:11 pm

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.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Patrik
Posts: 240
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Constraining DITA with xsd

Post by Patrik » Fri Aug 05, 2016 9:27 am

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

radu_pisoi
Posts: 375
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Constraining DITA with xsd

Post by radu_pisoi » Mon Aug 08, 2016 5:14 pm

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.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Post Reply