Schematron validation using context="/"

Having trouble installing Oxygen? Got a bug to report? Post it all here.
aujunior
Posts: 43
Joined: Thu Feb 16, 2023 11:00 pm

Schematron validation using context="/"

Post by aujunior »

Hello!

We are implementing schematron validation in our environment.

We noticed that when using the <sch:rule context="/"> instruction when there is an assert or a report, Oxygen is not pointing out where the error occurred.

Could you tell me if this is because the context is "/" or if it is a feature of Oxygen?

We noticed that when the context is "/" the "Location" is empty.
image.png

We would also like to know if it is possible to set a validation scenario dynamically via Java.

Best,
Audye
You do not have the required permissions to view the files attached to this post.
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Schematron validation using context="/"

Post by Radu »

Hi Audye,
The XPath "/" means the entire document node context (containing the root element and the possible comments/processing instructions before and after it), so it's not even the root element context. The root element xpath context is "/*". So this is probably why Oxygen does not handle this unusual case as usually the context is set to be the closest element on which the problem should be checked.
About this remark:
We would also like to know if it is possible to set a validation scenario dynamically via Java.
Can you elaborate on why a framework configuration is not enough?
Also do you want the validation scenario to validate also with Schematron or to validate with your custom Java code?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
aujunior
Posts: 43
Joined: Thu Feb 16, 2023 11:00 pm

Re: Schematron validation using context="/"

Post by aujunior »

Hello Radu!

I'm sorry for taking so long to respond.

Thank you very much for indicating the "/*" context, however, we tested and found that this way all errors are highlighted in the first element of the XML file.

We are working with S1000D and we noticed that some checks do not have a defined context, for example:

Code: Select all

//*[not(self::security)]/@securityClassification
. In this scenario we would like the error to be pointed out in the element that contains the "securityClassification" attribute and which is not the "security" element, however, as the context is "/*" the system is pointing to the element that starts the file.

We imagined that <sch:rule context> would serve to indicate what the context of the check is and that Oxygen would point <sch:report>/<sch:assert> to the element where the condition was affected.


Regarding the configuration of the framework, the company's internal engineering team requested the creation of 3 different validation scenarios. And they would like to choose the validation scenario before opening the file or while editing the file. Could you tell me if Oxygen Web has a mechanism for choosing a validation scenario?


We verified that Oxygen Desktop allows you to choose the validation scenario. There is the default scenario, but it contains a list of scenarios for the user to choose from. Is there something similar on Oxygen Web?
Maybe some user choice mechanism or some code that chooses the scenario when opening the file.

Best,
Audye
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Schematron validation using context="/"

Post by Radu »

Hello Audye,

Here's an example XML document:

Code: Select all

<root>
    <abc securityClassification="zz"></abc>
    <def></def>
</root>
and Schematron schema to validate it with:

Code: Select all

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
    xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
    <sch:pattern>
        <sch:rule context="*[not(self::security)]/@securityClassification">
            <sch:report test="true()">REPORT ME</sch:report>
        </sch:rule>
    </sch:pattern>
</sch:schema>
When I validate the XML document with the Schematron schema, only the "<abc " element is highlighted with an error.
If that does not work in your case maybe you can give me a similar example where this does not work.

Please see some more remarks below:
Regarding the configuration of the framework, the company's internal engineering team requested the creation of 3 different validation scenarios. And they would like to choose the validation scenario before opening the file or while editing the file.
Usually Oxygen detects a framework configuration and uses its associated validation scenario depending on the XML contents. Can anything (maybe attribute set on root element) inside the XML document be used to auto detect the used Schematron schema?
We verified that Oxygen Desktop allows you to choose the validation scenario. There is the default scenario, but it contains a list of scenarios for the user to choose from.
The desktop application is more flexible as it covers also more expert XML developers.
Is there something similar on Oxygen Web?
WebAuthor is mostly for people using visual editing and who do not know what Schematron is. Maybe somehow a GET parameter could be passed to determine the used Schematron schema but I'm not sure if this is possible, I will ask my colleagues from the WebAuthor team to help us with this one and reply on the thread further.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Schematron validation using context="/"

Post by Radu »

Hi,
About the WebAuthor tool, all its possible GET parameters are listed here:
https://www.oxygenxml.com/doc/versions/ ... r-app.html

There is this parameter:
schematron.imposed.phase - This parameter can be used to impose the Schematron phase to use when validating with a Schematron file.
which would mean that if inside the Schematron used for validation there would be multiple phases, each with its rules, this parameter could be used to impose a certain phase for validation.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
aujunior
Posts: 43
Joined: Thu Feb 16, 2023 11:00 pm

Re: Schematron validation using context="/"

Post by aujunior »

Hi,
Thank you very much Radu for your recommendation.

Yesterday I spent the day testing some options.

We can join the three Schematrons we have into one and separate them using the <sch:phase> instruction. So when we open the XML for editing we can send the "schematron.imposed.phase" parameter via URL.

I have one last question, could we use the "ValidationScenarioInvoker" method from the "ro.sync.exml.workspace.api.editor.validation" package to programmatically run a validation scenario?

Best,
Audye
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Schematron validation using context="/"

Post by Radu »

Hi Audye,

About this question:
I have one last question, could we use the "ValidationScenarioInvoker" method from the "ro.sync.exml.workspace.api.editor.validation" package to programmatically run a validation scenario?
Right now the method "ValidationScenarioInvoker.runValidationScenarios(String[])" is implemented and works for the desktop Oxygen but from what I checked it does not work for Web Author.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply