Check Relax NG Grammar with Schematron?

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
fsteimke
Posts: 41

Check Relax NG Grammar with Schematron?

Mon Jan 05, 2015 10:45 am

Hi,
i have a Relax NG Schema, that is, a grammr Element in the http://relaxng.org/ns/structure/1.0 namespace. I would like to check wheter al elements defined in this grammar are properly documented. So i wrote a schematron Schema which reports all elements without a a:documentation child.

However, i was unable to assign the schematron schema to the Relax NG Document. The Menu Item for "Assign Schema" is grayed out. So i wrote a xml-model instruction like this (it was copy-pasted from a normal XML Document, where the schematron file was assigned to without any problems):

Code: Select all

<?xml-model href="constraint.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>


But this does not work either. It seems to me that this PI is completely ignored when validating the Relax NG Document.

To conclude: my question is, is there a way to check semantic constraints on RELAX NG grammars with self-defined Schematron rules?

Sincerely,
Frank
radu_pisoi
Posts: 327
Location: Craiova

Re: Check Relax NG Grammar with Schematron?

Mon Jan 05, 2015 6:43 pm

Hi Frank,

fsteimke wrote:However, i was unable to assign the schematron schema to the Relax NG Document. The Menu Item for "Assign Schema" is grayed out.


This action was disabled deliberately because there are some situations when it could be used erroneously. For instance, I think there is no reason to associate a DTD schema or another RNG schema with the current edited RNG document.

However, if you want to validate your RNG document as a regular XML document then you could open it as an XML document(from the Project view you have to use the contextual action "Open with" -> "Internal editor". This action will display a dialog in which you should select the "XML document" entry). The RNG document will be opened with the XML editor that allows you to associate and validate the edited document with an external schema.

fsteimke wrote:To conclude: my question is, is there a way to check semantic constraints on RELAX NG grammars with self-defined Schematron rules?

In my opinion, the best solution is to create a validation scenario for the RNG document. This allows you to edit it as a normal RNG document and also to check it against a Schematron schema.
Next, I will give you two ways to define a validation scenario and you have to choose one depending on your needs.

1. The first and fastest solution is to create and associate a validation scenario for the edited RNG document. This assumes that the RNG document is already opened in the application.

* To create a new validatin scenario click the 'Configure the validation Scenario(s)' action from the toolbar. This action will display an dialog that allows you to manage the validation scenarios.
* Create a new one by clicking the New button. In the new displayed dialog you will define your validation scenario by specifying two validation units:
** the first validation unit will validate your document as a normal RNG document;
** the second validation unit will validate your document as an XML document against your Schematron schema.

* After you have defined the validation units press OK to confirm the new created scenario.
* To use it, you should associate it with the edited document (the checkbox from the right side of the scenario name should be checked).

Press 'Apply associated' and your document will be validated twice: first as an RNG document and second with the specified Schematron schema.

More about validation scenarios could be found here:
http://www.oxygenxml.com/doc/ug-editor/ ... nario.html

2. If you want to impose these rules to any RNG document (elements from any RNG document should been documented), you could define a default validation scenario for the 'Relax NG' document type. In this case, when you validate a RNG document it will be validated also against the rules defined in the Schematron schema.

To edit the Relax NG document type in order to add a new default validation scenario you have to follow this procedure:
* Open the Preferences dialog by using the menu action: Options/Preferences
* Find the 'Document Type Association' options page, the easiest way is to write 'Document Type Association' in the quick filter;
3. Find and edit the 'Relax NG' document type
4. In the 'Document Type' dialog select the Validation tab
5. Define a new validation scenario similar with the one created above;
6. To make it the default validation scenario you have to select it in 'Validation' tab

Please see more details here:
http://www.oxygenxml.com/doc/ug-editor/ ... arios.html

Do not hesitate to contact us if you have additional questions.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
fsteimke
Posts: 41

Re: Check Relax NG Grammar with Schematron?

Tue Jan 06, 2015 12:04 am

Thank you Radu for this quick and extensive answer.

I tried the first alternative, and it works very well. Exactly what i was looking for.

Sincerely,
Frank
Frank Ralf
Posts: 365
Location: Hamburg

Re: Check Relax NG Grammar with Schematron?

Fri Feb 13, 2015 6:16 pm

Hi Radu,

Thanks for these thorough instructions!

I had the problem that my RNG files wouldn't validate and noticed after some investigation that the RELAX NG document type doesn't have a default validation scenario activated as for example the DITA document types. Is there a reason for this?

Kind regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Frank Ralf
Posts: 365
Location: Hamburg

Re: Check Relax NG Grammar with Schematron?

Fri Feb 13, 2015 6:33 pm

I forgot to mention that I'm using oXygen Author at the moment so this might be different with the full fledged oXygen Editor version.

Kind regards,
Frank

PS:
The same goes for Schematron files, there is no (default) validation scenario associated with the document type.
Frank Ralf
parson AG
www.parson-europe.com
adrian
Posts: 2443

Re: Check Relax NG Grammar with Schematron?

Fri Feb 13, 2015 9:45 pm

Hello,

Oxygen only provides validation scenarios for some XML document types (where necessary), but in general none for schemas. With regard to schemas Oxygen XML Editor (and also Developer) provides for each type of schema a specialized editor (in some cases with a diagram) that handles validation with specific engines, content completion and various helpers (Outline, locate declarations, references, etc).
On the other hand, Oxygen XML Author does not have any of these specialized schema editors, nor does it provide validation for schemas (which is bound to the type of editor). So, if you open any type of schema in Author, it is treated as vanilla XML.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 2 guests