Schematron issue validating conrefs

Having trouble installing Oxygen? Got a bug to report? Post it all here.
bdew
Posts: 11
Joined: Mon Mar 03, 2014 5:11 pm
Location: Shawnee, KS

Schematron issue validating conrefs

Post 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,
Bryan
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Schematron issue validating conrefs

Post 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
Radu
Posts: 9449
Joined: Fri Jul 09, 2004 5:18 pm

Re: Schematron issue validating conrefs

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Schematron issue validating conrefs

Post 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
Post Reply