Page 1 of 1

Further development on schematron

Posted: Mon Mar 23, 2015 10:11 am
by Patrik
I have some ideas/requirements on improvement for schematron. However, it seems there is no more any development ongoing since the latest news on http://www.schematron.com/index.html is 5 years old and the mailing lists appear to be dead as well.

I there any clean way to make adjustments to the schematron files (I guees it would be xslt stylesheets) and distribute them to my collegues (similar to custom document types) and possibly even back to oxygen?

Thanks and regards

Patrik

Re: Further development on schematron

Posted: Tue Mar 24, 2015 7:10 pm
by adrian
Hello,

There is a relatively clean way of making adjustments, but you do need to patch Oxygen's builtin stylesheets. So with any change you make to the stylesheets you will most likely need to restart the application.

A copy of the Schematron stylesheets that Oxygen uses can be found in "Oxygen\frameworks\schematron\impl". So if you want to make any changes, you can use these as the base template.
Since this is just a copy, not the actual stylesheets that Oxygen uses when validating with Schematron, you will have to deploy them in the Oxygen folder after making changes. Navigate to "Oxygen/lib" and create a folder named "endorsed" and inside it another folder named "builtin". Place the modified stylesheets there, so they should all be located in "Oxygen/lib/endorsed/builtin".

Regards,
Adrian

Re: Further development on schematron

Posted: Wed Mar 25, 2015 12:28 pm
by Patrik
Thanks Adrian. It works.

Regards,
Patrik

Re: Further development on schematron

Posted: Thu Mar 26, 2015 6:26 pm
by Patrik
I successfully modified the iso-schematron-message.xsl. And the changes are in effect even without restarting oxygen.

However, modifying the schematronDispatcher.xsl or XSD2Schtrn.xsl didn't have any effect so far - even after restarting oxygen.

For instance in XSD2Schtrn.xsl I replaced line 80 (in template named "outputXSD")

Code: Select all

<xsl:apply-templates select="$schemas//xs:appinfo/iso:pattern" mode="copyAndAddLocationAttributes"/>
with the following test-code:

Code: Select all

<iso:pattern>
<iso:rule context="*">
<iso:assert test="false()">
TEST
</iso:assert>
</iso:rule>
</iso:pattern>
Still I got the actual messages from my xsd embedded schematron rules. Any ideas what I did wrong?

Thanks and regards,
Patrik

Re: Further development on schematron

Posted: Thu Mar 26, 2015 6:42 pm
by adrian
Hi,

If one works, so should the other. Check the names of the files (including the extension), they should have the same upper/lower casing as the builtin files:
- schematronDispatcher.xsl
- XSD2Schtrn.xsl

If it still doesn't work, zip the builtin folder with the files and change its extension to .jar. Leave the .jar in the Oxygen/lib/endorsed folder and restart Oxygen.

Regards,
Adrian

Re: Further development on schematron

Posted: Fri Mar 27, 2015 12:23 pm
by Patrik
I did as you told me - all without any effect. :(

Maybe you could give me a file (xsl, zip, jar or whatever is necessary) with any(!) noticable modification in schematronDispatcher that you tested successfully?

Thanks and regards,
Patrik

Re: Further development on schematron

Posted: Fri Mar 27, 2015 2:27 pm
by adrian
Hi,

Did you copy all the files from "Oxygen/frameworks/schematron/impl" to "Oxygen/lib/endorsed/builtin"? Or just the modified files? I mistakenly mislead you when I said to "place the modified stylesheets there", you need to copy all the files there, not just the modified ones.

Since it's a hierarchy of stylesheets with a patched module referred from another stylesheet, you need to place there the entire hierarchy, because the references between master and modules are relative and there are two possible locations for the resources (one in the "oxygen.jar/builtin" and the other "Oxygen/lib/endorsed/builtin"). So you can't make relative references to resources that are placed in the other location.

Please let me know if that wasn't it.

Regards,
Adrian

Re: Further development on schematron

Posted: Fri Mar 27, 2015 5:21 pm
by Patrik
I did copy all the xsl files, so it needs to be something else...

For testing I modified the files in the oxygen.jar/builtin and I worked - wouldn't be my preferred solution though.

Regards,
Patrik

Re: Further development on schematron

Posted: Sat Mar 28, 2015 3:45 pm
by Patrik
I figured out why it was not working with schematronDispatcher.xsl:
When doing schematron validation oxygen does not use the file schematronDispatcher.xsl directly but oXygenSchematronDispatcher.xsl. And this file imports schematronDispatcher.xsl with a relative path and, thus, within the oxygen.jar.

After adding a file oXygenSchematronDispatcher.xsl in the lib/endorsed/builtin folder it did overwrite the one from oxygen.jar.

And when just placing an <xsl:include href="urn:..."/> in it I can maintain and distribute my modified files in any folder distributed to my colleagues via version control system. :)

Regards,
Patrik

Re: Further development on schematron

Posted: Mon Mar 30, 2015 12:14 pm
by adrian
Hello,

You are, of course, correct. I was out of the loop on this one. oXygenSchematronDispatcher.xsl has been introduced starting with v15.2 for a better line/column location of the Schematron warnings/errors. This is the master XSL (instead of schematronDispatcher.xsl) used by Oxygen, that's why the patch did not work.
If you haven't already, you can extract oxygen.jar/builtin/oXygenSchematronDispatcher.xsl to Oxygen/lib/endorsed/builtin to make it work and not lose any functionality.

Regards,
Adrian

Re: Further development on schematron

Posted: Thu Jan 07, 2016 8:03 pm
by steve.cuzner
adrian wrote:
...

Since it's a hierarchy of stylesheets with a patched module referred from another stylesheet, you need to place there the entire hierarchy, because the references between master and modules are relative and there are two possible locations for the resources (one in the "oxygen.jar/builtin" and the other "Oxygen/lib/endorsed/builtin"). So you can't make relative references to resources that are placed in the other location.

...
We have IT policies that prevent us from modifying code in c:\Program Files, so putting the customized files in Oxygen/lib/endorsed/builtin is not an option. Is there a way to store these files outside of the program installation area and append the classpath to point to this new location?

Steve

Re: Further development on schematron

Posted: Thu Jan 07, 2016 8:22 pm
by Patrik
Hi Steve,

assuming that there is no easy solution with classpath or anything, this might be an acceptable workaround:
1. Create the file oXygenSchematronDispatcher.xsl at some folder where you are allowed to modify files.
2. Create another oXygenSchematronDispatcher.xsl file that only includes the first file.
3. Add the second file to the builtin folder once (with administration rights)

This way you have to modify only once code within the program files folder and can still modify the schematron behavior at any time.

Regards,
Patrik

Re: Further development on schematron

Posted: Thu Jan 07, 2016 9:20 pm
by adrian
Hi,

I'm afraid that for jar patches only the "Oxygen/lib/endorsed" folder can be used. A patch must override existing code from the builtin jars, so adding additional jars to the classpath would not be sufficient, the patch must come first.

However, if you can't use a jar patch, you can try a different approach which may actually be simpler, use an XML catalog with entries like this one for each XSL:

Code: Select all

<uriSuffix uriSuffix="oxygen.jar!/builtin/oXygenSchematronDispatcher.xsl " uri="oXygenSchematronDispatcher.xsl"/>
Place the XML catalog relative to your patched XSL files (they can be stored anywhere) and Configure the catalog in Options > Preferences, XML > XML Catalog.

Regards,
Adrian

Re: Further development on schematron

Posted: Mon Jan 11, 2016 4:17 pm
by adrian
Hi,

I've tested this and double checked and unfortunately it doesn't work for the particular example that I provided. oXygenSchematronDispatcher.xsl cannot be patched with XML catalogs, it simply does not pass through the XML catalog resolver.

However, you can patch the other stylesheets from the hierarchy that are imported or included in it.
For those, it works like this:

Code: Select all

<uri name="schematronDispatcher.xsl" uri="schematronDispatcher.xsl"/>
This allows you to patch schematronDispatcher.xsl (the import from oXygenSchematronDispatcher.xsl).

Regards,
Adrian