Run a Schematron validation scenario programmatically

Are you missing a feature? Request its implementation here.
aujunior
Posts: 42
Joined: Thu Feb 16, 2023 11:00 pm

Run a Schematron validation scenario programmatically

Post 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.
cosminef
Site Admin
Posts: 209
Joined: Wed Aug 30, 2023 2:33 pm

Re: Run a Schematron validation scenario programmatically

Post 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
Cosmin Eftenie
www.oxygenxml.com
aujunior
Posts: 42
Joined: Thu Feb 16, 2023 11:00 pm

Re: Run a Schematron validation scenario programmatically

Post 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.
mircea_b
Posts: 3
Joined: Fri Dec 08, 2023 12:51 pm

Re: Run a Schematron validation scenario programmatically

Post by mircea_b »

Hi,

A possible workaround could be to use a validation scenario that points to a schema using editor variables:
example.png
example.png (531.53 KiB) Viewed 277 times
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
aujunior
Posts: 42
Joined: Thu Feb 16, 2023 11:00 pm

Re: Run a Schematron validation scenario programmatically

Post by aujunior »

Thank you very much Mircea!

Your recommendation solved the problem.
Post Reply