Page 1 of 1

Run a Schematron validation scenario programmatically

Posted: Wed Jan 08, 2025 10:06 pm
by aujunior
Good afternoon,

Based on ticket post74532.html#p74532, we understand that it is only possible to programmatically run a Schematron validation scenario in Oxygen Desktop.

We would like to request the implementation of this feature in Oxygen XML Editor Web.

We are working with S1000D, where each project has its own Schematron with specific rules. Since our framework is designed to serve the application as a whole, we face the challenge of validating BREX information via Schematron for each project.

To address this issue, we had to extend our ".framework". In this extension, we manually linked the validation scenario to the corresponding project. However, if we could programmatically select the validation scenario via Java or JavaScript, we wouldn’t need to create specific extensions for each project.

In ticket 74532, it was stated that the ValidationScenarioInvoker.ValidationScenarios() method works only in the Oxygen Desktop version. Therefore, our feature request is to enable this validation to be invoked via Java in the Web environment as well.

Thank you very much for your attention.

Re: Run a Schematron validation scenario programmatically

Posted: Thu Jan 09, 2025 6:46 pm
by cosminef
Hello,

Thank you for contacting us.

In response to your request, we would like to suggest an alternative approach using the schematron.imposed.phase URL parameter [1].
The schematron.imposed.phase URL parameter is used to specify a particular phase of a Schematron schema to be applied when validating a document in Oxygen XML Web Author. This allows you to control which parts of the Schematron rules are executed during validation.

Do you think this alternative meets your needs?

Best,
Cosmin

Re: Run a Schematron validation scenario programmatically

Posted: Tue Jan 21, 2025 2:37 pm
by aujunior
Hello, Cosmin!

We are currently using your suggestion. We are sending the schematron.imposed.phase via URL and successfully validating the rules.

However, in our business, each model in S1000D uses at least three different Schematron files, each containing an average of 300 validations.

Initially, we compiled these three files into a single file and passed the phase via URL.

However, in the future, we will have around 20 different models, each with its own three Schematron files. If we consolidate all these validations into a single file, it might become so large that it won't even open, and it could potentially cause performance issues in the system.

Therefore, we believe it would be better to have the option to select the validation file directly via Java instead of just the phase. Additionally, it would be interesting if we could choose the Schematron validation file directly via URL instead of selecting only the phase. That would also address this issue.

Re: Run a Schematron validation scenario programmatically

Posted: Thu Jan 23, 2025 1:08 pm
by mircea_b
Hi,

A possible workaround could be to use a validation scenario that points to a schema using editor variables:
example.png
In this example, ${cfdu} is resolved to the path of the curent file directory.

You can create a custom handler that handles these requests and returns your desired schema:

Code: Select all

PluginWorkspaceProvider.getPluginWorkspace().getXMLUtilAccess().addPriorityURIResolver(
        new URIResolver() {
          
          @Override
          public Source resolve(String href, String base) throws TransformerException {
            if (href.endsWith("dynamic-schema.sch")) {
              if (base.contains("project1")) {
                // TODO: return schema for project 1
              } else if (base.contains("project2")) {
                // TODO: return schema for project 2
              }
            }
            // Let another handler handle this
            return null;
          }
        });


Hope this helps,
Mircea

Re: Run a Schematron validation scenario programmatically

Posted: Thu Feb 06, 2025 9:25 pm
by aujunior
Thank you very much Mircea!

Your recommendation solved the problem.

Re: Run a Schematron validation scenario programmatically

Posted: Mon Apr 28, 2025 8:00 pm
by kdolan09
Hi Cosmin,
We have a very similar situation to handle. I read through your post and will give the same a try but one thing I cannot figure out is - How/where do you configure the custom handler so that it is used? Any light you can shed on this would be much appreciated.
Thanks,
Kelly

Re: Run a Schematron validation scenario programmatically

Posted: Tue Apr 29, 2025 3:23 pm
by Bogdan Dumitru
Hello Kelly,

By "custom handler" I assume that you're referring to the URIResolver from Mircea's message, the one installed with PluginWorkspaceProvider.getPluginWorkspace().getXMLUtilAccess().addPriorityURIResolver.

To install the URI Resolver you have to execute the Java code that calls PluginWorkspaceProvider.getPluginWorkspace().getXMLUtilAccess().addPriorityURIResolver when applications starts in a plugin based on Oxygen SDK. You can define in plugin.xml an extension of type "WorkspaceAccess" that must refer to a class that implements ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension interface from Oxygen SDK. On the WorkspaceAccessPluginExtension.applicationStarted implementation you should call addPriorityURIResolver.

Here are some useful links:
1. a sample plugin that uses "WorkspaceAccess" extension type https://github.com/oxygenxml/web-author ... ems-filter
2. Oxygen SDK page where you should find the JavaDoc of the above-mentioned classes: https://www.oxygenxml.com/oxygen_sdk.html
3. documentation page about Web Author plugins: https://www.oxygenxml.com/doc/versions/ ... ugins.html