Page 1 of 1
Schematron issue validating conrefs
Posted: Thu May 07, 2015 9:13 pm
by bdew
We are currently validating note types, among other things, in our .dita files through Oxygen (v14.2). And all seems to work well, except when trying to validate notes that are conrefs. The validation appears to ignore or not check the conrefs.
Is there something I need to add to my existing validation for conrefs?
Currently we are using:
Code: Select all
<pattern id="note">
<rule context="*[contains(@class, ' topic/note ')]">
<assert test="descendant::*[contains(@class, ' topic/note ')][@type='note' or @type='tip' or @type='caution']" role="warning">
Note element type must be note, tip, or caution.
</assert>
</rule>
</pattern>
Any help would be much appreciated!
Thanks,
Re: Schematron issue validating conrefs
Posted: Fri May 08, 2015 8:33 am
by Patrik
Hi Bryan
not sure about your problem with conref (from my experience, schematron validation applies to conrefs as well). But assuming you simply want to check that the attribute of a note element contains one of the valid values, your code is wrong: It checks for the existence of an additional note element as child of the original one.
This code should work (It does for me with Oxygen 16.0):
Code: Select all
<pattern id="note">
<rule context="*[contains(@class, ' topic/note ')]">
<assert test="@type='note' or @type='tip' or @type='caution'" role="warning">
Note element type must be note, tip, or caution.
</assert>
</rule>
</pattern>
And the xpath could also be simplified to
Code: Select all
<assert test="@type = ('note', 'tip', 'caution')" role="warning">
Regards,
Patrik
Re: Schematron issue validating conrefs
Posted: Fri May 08, 2015 8:53 am
by Radu
Hi Bryan, Patrik,
Schematron validation is applied on the DITA/XML document as it is, without expanding the conrefs before the validation.
So you can either skip for validation elements which have the conref attribute set on them or you could try to resolve the conref yourself, to load the target document as a nodeset using the Schematron function document and to locate in it the element with the proper ID specified, then to validate that element's content. So it's a bit of work to do. There is a Schematron stylesheet in:
OXYGEN_INSTALL_DIR\frameworks\dita\resources\dita-1.2-for-xslt2-links-checker.sch
which tries to check if an xref points to a valid element ID, that could be a starting point for you.
Regards,
Radu
Re: Schematron issue validating conrefs
Posted: Fri May 08, 2015 10:43 am
by Patrik
I checked again and can confirm that for me the schematron validation doesn't apply to (standard-)conrefs as well. We just have a special use-case for a "copy-conref" where the referenced content is (automatically) copied into the document. And there - of course - the content is validated as well.
Regards,
Patrik