Page 1 of 1
Using XSLT for Schematron
Posted: Fri Mar 14, 2008 3:31 pm
by PaulHermans
I have following working xsl using Saxon-SA.
Code: Select all
<xsl:import-schema schema-location="file:///dcterms-elem.xsd" namespace="http://purl.org/dc/terms/"/>
<xsl:template match="element(*, dcterms:TripleType)">
<xsl:value-of select="name()"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates/>
</xsl:template>
Now I want to use the same pattern in a schematron validation
Code: Select all
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<ns uri="http://purl.org/dc/terms/" prefix="dcterms"/>
<pattern>
<rule context="element(*, dcterms:TripleType)">
<assert test="self::*">
<value-of select="name()"/></assert>
</rule>
</pattern>
</schema>
When running the schematron validation the XSLT 2.0 processor complains
.
What am I missing?
Paul
Re: Using XSLT for Schematron
Posted: Sat Mar 15, 2008 9:44 am
by george
Hi Paul,
The xsl:import is missing:
<xsl:import-schema schema-location="file:///dcterms-elem.xsd" namespace="
http://purl.org/dc/terms/"/>
You can check that passing the Schematron schema through the skeleton and then looking at the generated XSLT stylesheet.
Best Regards,
George
Re: Using XSLT for Schematron
Posted: Sat Mar 15, 2008 12:38 pm
by PaulHermans
Of course,
But what needs to be added/changed in the schematron schema so that the xsl-import-schema element is automaticalle generated in the intermediate xslt 2.0 file?
Paul
Re: Using XSLT for Schematron
Posted: Mon Mar 17, 2008 6:12 pm
by george
Hi Paul,
There is basically no change that you can do in the shcema for Schematron... What can be done however is to add support for xsl:import-schema in skeleton in a way similar with the support for xsl:key.
Try the following changes in ISO Schematron skeleton:
In <xsl:template match="*" mode="stylesheetbody"> add
Code: Select all
<xsl:text> </xsl:text><xsl:comment>XSL IMPORT SCHEMA</xsl:comment><xsl:text> </xsl:text>
<xsl:apply-templates mode="do-xsl-import-schema" select="xsl:import-schema"/>
after <xsl:call-template name="process-prolog"/>.
add
Code: Select all
<xsl:template match="xsl:import-schema" mode="do-xsl-import-schema" >
<xsl:if test="not(@schema-location)">
<xsl:message>Markup Error: no schema-location attribute in <import-schema></xsl:message>
</xsl:if>
<xsl:if test="not(@namespace)">
<xsl:message>Markup Error: no namespace attribute in <import-schema></xsl:message>
</xsl:if>
<xsl:if test="@schema-location and @namespace">
<axsl:import-schema>
<xsl:copy-of select="@*"/>
</axsl:import-schema>
</xsl:if>
</xsl:template>
<xsl:template match="xsl:import-schema" /><!-- swallow -->
<xsl:template match="text()" priority="-1" mode="do-xsl-import-schema">
<!-- strip characters -->
</xsl:template>
Best Regards,
George
Re: Using XSLT for Schematron
Posted: Wed Mar 19, 2008 6:16 pm
by PaulHermans
There seems to be another option, from a mail from David Carlisle.
just put the line into your schematron schema and tell the processor to
copy foreign (ie non-schematron) elements to the generated xsl, using
allow-foreign=true
see
http://eccnet.eccnet.com/pipermail/sche ... 00693.html
which is to access xsl:function, but the same should work for
<xsl:import-schema
In OxygenXML you expose already the optimize parameter. Is it an option to also expose the allow-foreign parameter.
Paul
Re: Using XSLT for Schematron
Posted: Thu Mar 20, 2008 7:00 pm
by george
Hi Paul,
Sure, that can be an option. We already added that in the current development stream. However, there is a need also to allow executing Schematron with xslt2 binding with Saxon 9 SA. Currently we use Saxon 9B. Probably we need to add that also as an option.
Best Regards,
George
Re: Using XSLT for Schematron
Posted: Fri Mar 21, 2008 1:00 pm
by PaulHermans
However, there is a need also to allow executing Schematron with xslt2 binding with Saxon 9 SA. Currently we use Saxon 9B. Probably we need to add that also as an option.
Indeed, the case I'm working on needs Saxon 9 SA.
Thanks for putting this in.
Paul
Re: Using XSLT for Schematron
Posted: Wed Apr 02, 2008 5:23 pm
by george
Hi Paul,
The option to use Saxon SA for the xslt2 query binding was added and all these will be available in the next oXygen maintenance release, version 9.2.
Best Regards,
George
Re: Using XSLT for Schematron
Posted: Wed Apr 02, 2008 5:29 pm
by PaulHermans
Great.
Thanks for the follow-up.
Paul
Re: Using XSLT for Schematron
Posted: Tue Apr 15, 2008 1:11 pm
by PaulHermans
Testing the 9.2 beta version with saxon-sa 9.0.0.4.
Different result if:
a) running an external validation using a schematron schema with xslt2 binding and
<xsl:import-schema ...>
and preferences allow foreign elements set to true and use saxon-sa for xslt 2.0 binding.
Code: Select all
SystemID: /Users/Paul/Desktop/Projects/ICTU/examples/vac-20080403.xml
Location: 16:0
Description: Gebruikte waarde "Utrecht" komt niet voor in cv "http://standaarden.overheid.nl/owms/3.5/xml/Waardelijst/OVERHEID.Gemeente.xml". (. = document(concat($path, $prefix, '.', $cv, '.xml'))/x:cv/x:cvvalue)
Which is a non schema aware error message
b) running the iso_schematron_skeleton_for_saxon.xsl on the schematron file with parameter allow-foreign=true
followed by the validation of the source by running the generated stylesheet by saxon-sa.
Code: Select all
Element met naam dcterms:subject heeft nu geen enkele waarde, noch als
content, noch in @scheme, noch in @resourceIdentifier. Eén van de drie moet ingevuld zijn.
Which is a schema aware error message.
Any idea where the difference comes from?
Or is the preference not working in case a)?
Thanks for the help.
Paul
Re: Using XSLT for Schematron
Posted: Tue Apr 15, 2008 4:30 pm
by george
Hi Paul,
We have a few automatic tests that check that these features work. It may be something particular with a specific example... Can you send us a cut down sample to reproduce the problem? It will also help if the messages will be in English

.
Best Regards,
George
Re: Using XSLT for Schematron
Posted: Tue Apr 15, 2008 8:31 pm
by PaulHermans
Files have been sent to the support mail address.
Paul
More research done: Using XSLT for Schematron
Posted: Thu Apr 17, 2008 12:09 pm
by PaulHermans
Dear George,
When I run the XSLT transform with SAXONSA outside Oxygen beta with command line param:
-sa only
I get the same result as within Oxygen external Schematron validation with allow-foreign and SaxonSA preferences
-sa and -val
the schema aware transformation works.
I have however in the general SAXONSA XSLT preferences -val set to true, but this doesn't seem to be picked up during the schematron validation.
My hypothesis at least.
Paul
Re: Using XSLT for Schematron
Posted: Thu Apr 17, 2008 12:24 pm
by george
Hi Paul,
That is exactly our finding - I was just about to post that...

We will set the options we have in oXygen for Saxon SA also when we use the processor for Schematron, that should allow the users to control the options.
Best Regards,
George