Page 1 of 1

RELAX NG with Embedded Schematron

Posted: Thu Apr 14, 2016 8:41 am
by tmakita
Hi,

I'm trying to validate DITA topic by RELAX NG including Schematron.
But validating the scenario "Validate Relax NG with embedded Schematron" does not report any expected errors.
Could you take a look at this? I'm new to both RELAX NG and Schematron.

Code: Select all

      <define name="floatfig.element">
<element name="floatfig" dita:longName="Floating figure">
<a:documentation> The Floating Figure element (<floatfig>) represents
an figure to be rendered as a floating figure that fits left or right side. The contents are almost same as fig
without <floatfig-group>.
</a:documentation>
<sch:pattern name="Test constraints on the floatfig element">
<sch:rule context="floatfig">
<sch:assert test="(string(@float) ne 'none') and exists(child::floatfig-group)">floatfig-group should not appear if floatfig/@float ne 'none'</sch:assert>
<sch:assert test="true()">Schematron floatfig-group test</sch:assert>
</sch:rule>
</sch:pattern>
<ref name="floatfig.content"/>
<ref name="floatfig.attlist"/>
</element>
</define>
The steps are following:

1. Download the my DITA-OT plug-in.
https://onedrive.live.com/redir?resid=9 ... file%2czip
2. Copy "com.antennahouse.dita.dita13.doctypes" to dita-ot-2.2.3/plugins folder.
3. Run "ant -f integrator.xml" or "dita -install".
4. Open dita-ot-2.2.3/plugins/com.antennahouse.dita.dita13.doctypes/ah_dita13_doctypes.xpr by oXygen.
5. Open testdata/test-rng-task.xml. The relevant RNG file is doctypes/rng/technicalContent/rng/task.rng and base/rng/floatfigDomain.rng.
6. Validate test-rng-task.xml via "Validate Relax NG with embedded Schematron" schenario.

Regards,

Toshihiko Makita

Re: RELAX NG with Embedded Schematron

Posted: Thu Apr 14, 2016 11:32 am
by Radu
Hi Toshihiko,

Thanks for the samples.
This is a small bug in Oxygen, we use an XSLT stylesheet to gather all Schematron patterns from the Relax NG patterns and the XSLT stylesheet should also look in imports but in this case, if you look in the task.rng, it has a <div> in which the includes appear:

Code: Select all

  <div>
<a:documentation> MODULE INCLUSIONS </a:documentation>
.....
If you remove that <div> wrapper from around the includes, Oxygen will start applying the Schematron patterns you created on validation.
You have a small problem in your pattern, an sch:pattern does not have a @name attribute, it should have an @id attribute instead with an ID-type value.
We'll also fix this on our side, allow for looking for Schematron patterns also in RNGs included in <div> blocks.

Regards,
Radu

Re: RELAX NG with Embedded Schematron

Posted: Thu Apr 14, 2016 11:46 am
by tmakita
Hi Radu,

Thank you for your quick reply.
You have a small problem in your pattern, an sch:pattern does not have a @name attribute, it should have an @id attribute instead with an ID-type value.
Sorry it's my mistake.
By the way do you have any Schematron books or resources that can be used for DITA RELAX NG schemas?
I have searched Amazon or others but no effective resources cannot be found.
If you have any recommendations, please let me know.

Regards,

Toshihiko Makita

Re: RELAX NG with Embedded Schematron

Posted: Thu Apr 14, 2016 11:48 am
by Radu
Hi,

You could try this book from O'Reilly:

http://shop.oreilly.com/product/9780596527716.do

Ideally you would first develop the Schematron as a standalone file (because Oxygen offers better content completion and validation when doing this) and when it is final you can copy its patterns to the RNG or keep it as a separate Schematron file and refer to it directly from the DITA topic.

Regards,
Radu

Re: RELAX NG with Embedded Schematron

Posted: Thu Apr 14, 2016 3:38 pm
by tmakita
Hi,
I bought it!
Thank you very much.

Regards,

Toshihiko Makita

Re: RELAX NG with Embedded Schematron

Posted: Fri Apr 22, 2016 4:12 pm
by tmakita
This is a small bug in Oxygen, we use an XSLT stylesheet to gather all Schematron patterns from the Relax NG patterns and the XSLT stylesheet should also look in imports but in this case, if you look in the task.rng, it has a <div> in which the includes appear:
I've confirmed that this bug is fixed in oXygen 18.0.
Thank you!

Regards,

Toshihiko Makita

Re: RELAX NG with Embedded Schematron

Posted: Fri Apr 22, 2016 4:19 pm
by Radu
Hi,

No problem, thanks for confirming the problem is fixed.

Regards,
Radu

Re: RELAX NG with Embedded Schematron

Posted: Fri Apr 22, 2016 4:48 pm
by tmakita
Hi Radu,

> I've confirmed that this bug is fixed in oXygen 18.0.

Sorry, it's my mistake.
oXygen 18.0 output the following error message:
System ID: D:\DITA-OT\dita-ot-2.2.3\plugins\com.antennahouse.dita.dita13.doctypes\testdata\test-rng-task.xml
Main validation file: D:\DITA-OT\dita-ot-2.2.3\plugins\com.antennahouse.dita.dita13.doctypes\testdata\test-rng-task.xml
Scenario name: Validate Relax NG schema with embedded Schematron - current file
Schema: D:\DITA-OT\dita-ot-2.2.3\plugins\com.antennahouse.dita.dita13.doctypes\doctypes\rng\technicalContent\rng\task.rng
Engine name: ISO Schematron
Severity: error
Description: floatfig-group should not appear if floatfig/@float ne 'none'
Start location: 29:41
But the relevant error point is not accurate. This error message indicates that following authoring is error:

[testdata/test-rng-task.xml line 29]
```
<stepsection fo:prop="font-style:bold;">
<floatfig float="right">
<title>Title of this floating figure</title>
<image href="http://www.antenna.co.jp/images/test-float.jpg"></image>
<dl>
<dlentry>
<dt>1</dt>
<dd>Description of the figure</dd>
</dlentry>
</dl>
</floatfig>
</stepsection>
```

But this authoring is not error because Schematron coding is as follows:

[com.antennahouse.dita.dita13.doctypes\doctypes\rng\base\rng\floatfigDomain.rng line 103]
```
<sch:pattern id="Test_constraints_on_the_floatfig_element">
<sch:rule context="floatfig">
<sch:assert test="(string(@float) ne 'none') and exists(child::floatfig-group)">floatfig-group should not appear if floatfig/@float ne 'none'</sch:assert>
</sch:rule>
</sch:pattern>
```

So the error should be occurred in the following authoring:

[testdata/test-rng-task.xml line 44]
```
<stepsection>
<floatfig float="left">
<floatfig-group float="left">
<title>Title of this floating figure</title>
<image href="http://www.antenna.co.jp/images/test-fl ... g"></image>
<dl>
<dlentry>
<dt>1</dt>
<dd>Description of the figure</dd>
</dlentry>
</dl>
</floatfig-group>
<floatfig-group float="right">
<title>Title of this floating figure</title>
<image href="http://www.antenna.co.jp/images/test-fl ... g"></image>
<dl>
<dlentry>
<dt>1</dt>
<dd>Description of the figure</dd>
</dlentry>
</dl>
</floatfig-group>
</floatfig>
</stepsection>
```

Can you take a look this again?

The all of the test data is in GitHub repository.

https://github.com/AntennaHouse/ah-dita/

The steps to reproduce are:

1. Download com.antennahouse.dita.dita13.doctypes.
2. Copy this folder dita-ot-2.2.3\plugins.
3. Run "ant -f integrator".
4. Open dita-ot-2.2.3\plugins\com.antennahouse.dita.dita13.doctypes\ah_dita13_doctypes.xpr by oXygen.
5. Open dita-ot-2.2.3\plugins\com.antennahouse.dita.dita13.doctypes\testdata\test-rng-task.xml.
6. Validate it by Ctrl + shift + V.

Regards,

Re: RELAX NG with Embedded Schematron

Posted: Tue Apr 26, 2016 2:53 pm
by tavy
Hello,

If you want the error to be displayed on the "floatfig" element when the @float attribute is not "none" and you do not have the "floatfig-group" as child then you need to change the assert.
Instead of <sch:assert test="(string(@float) ne 'none') and exists(child::floatfig-group)">
You should use: <sch:report test="(string(@float) ne 'none') and exists(child::floatfig-group)">

Best Regards,
Octavian

Re: RELAX NG with Embedded Schematron

Posted: Wed Apr 27, 2016 11:32 am
by tmakita
Hi,

I misunderstood the role of "assert" and "report".
The former displays message when @test become false().
In contrast the latter displays message when @test become true().

This is my primary mistake.

Regards,