Using XSLT for Schematron
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
Using XSLT for Schematron
Post by PaulHermans »
I have following working xsl using Saxon-SA.
Now I want to use the same pattern in a schematron validation
When running the schematron validation the XSLT 2.0 processor complains
What am I missing?
Paul
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>
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>
.No schema has been imported for namespace 'http://purl.org/dc/terms/'
What am I missing?
Paul
Paul
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Using XSLT for Schematron
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
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
George Cristian Bina
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
Re: Using XSLT for Schematron
Post 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
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
Paul
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Using XSLT for Schematron
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
after <xsl:call-template name="process-prolog"/>.
add
Best Regards,
George
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"/>
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>
George
George Cristian Bina
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
Re: Using XSLT for Schematron
Post by PaulHermans »
There seems to be another option, from a mail from David Carlisle.
Paul
In OxygenXML you expose already the optimize parameter. Is it an option to also expose the allow-foreign parameter.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
Paul
Paul
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Using XSLT for Schematron
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
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
George Cristian Bina
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
Re: Using XSLT for Schematron
Post by PaulHermans »
Indeed, the case I'm working on needs Saxon 9 SA.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.
Thanks for putting this in.
Paul
Paul
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Using XSLT for Schematron
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
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
George Cristian Bina
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
Re: Using XSLT for Schematron
Post 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.
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.
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
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)
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.
Any idea where the difference comes from?
Or is the preference not working in case a)?
Thanks for the help.
Paul
Paul
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Using XSLT for Schematron
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
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
George Cristian Bina
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
Re: Using XSLT for Schematron
Post by PaulHermans »
Files have been sent to the support mail address.
Paul
Paul
Paul
-
- Posts: 82
- Joined: Sat Jan 13, 2007 5:39 pm
- Location: Belgium
More research done: Using XSLT for Schematron
Post 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
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
Paul
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Using XSLT for Schematron
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
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
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service