<?xml version="1.0"?><?xar XSLT?>
<!--
OVERVIEW
ASCC/Schematron.com Skeleton Module for ISO Schematron (for XSLT1 systems)
ISO Schematron is a language for making assertion about the presence or absence
of patterns in XML documents. It is typically used for as a schema language, or
to augment existing schema languages, and to check business rules. It is very
powerful, yet quite simple: a developer only need know XPath and about five other
elements.
This is an open source implementation of ISO Schematron in XSLT. Although ISO does
not allow reference implementations which might compete with the text of the
standard, this code has been compiled by Rick Jelliffe, inventor of Schematron
and editor of the ISO standard; so developers can certainly use it as an
unofficial reference implementation for clarification.
This implementation is based on one by Oliver Becker. API documentation is
available separately; try www.schematron.com for this. Funding for this
stylesheet over the years has come from Topologi Pty. Ltd., Geotempo Ltd.,
and ASCC, Tapei.
There are two versions of this skeleton: one is tailored for XSLT1 processors
and the other is tailored for XSLT2 processors. Future versions of the
XSLT2 skeleton may support more features than that the XSLT 1 skeleton.
-->
<!--
TIPS
A tip for new users of Schematron: make your assertions contain positive messages
about what is expected, rather than error messages. For example, use the form
"An X should have a Y, because Z".
Another tip is that Schematron provides an
element <sch:ns> for declaring the namespaces and prefixes used in Xpaths in
attribute values; it does not extend the XML Namespaces mechanism: if a name
in an XPath has a prefix, there must be an <sch:ns> element for that prefix; if
a name in an XPath does not have a prefix, it is always in no namespace.
A tip for implementers of Schematron, either using this API or re-implementing it:
make the value of the diagnostics, flags and richer features available if possible;
Schematron has many of the optional richer features which, if implemented, provide
a compelling alternative approach to validation and business-rules checking compared
to other schema languages and programs.
If you create your own meta-stylesheet to override this one, it is a
good idea to have both in the same directory and to run the stylesheet
from that directory, as many XSLT implementations have ideosyncratic
handling of URLs: keep it simple.
-->
<!--
INVOCATION INFORMATION
The following parameters are available
phase NMTOKEN | "#ALL" (default) Select the phase for validation
allow-foreign "true" | "false" (default) Pass non-Schematron elements to the generated stylesheet
sch.exslt.imports semi-colon delimited string of filenames for some EXSLT implementations
message-newline "true" (default) | "false" Generate an extra newline at the end of messages
optimize "visit-no-attributes"
debug "true" | "false" (default) Debug mode lets compilation continue despite problems
attributes "true" | "false" (Autodetecting) Use only when the schema has no attributes as the context nodes
only-child-elements "true" | "false" (Autodetecting) Use only when the schema has no comments
or PI as the context nodes
The following parameters can be specified as Schematron variables in diagnostics, assertions and so on.
fileNameParameter string
fileDirParameter string
archiveNameParameter string In case of ZIP files
archiveDirParameter string In case of ZIP files
output-encoding Use when outputting to XML
Experimental: USE AT YOUR OWN RISK
visit-text "true" "false" Also visist text nodes for context. WARNING: NON_STARDARD.
select-contents '' | 'key' | '//' Select different implementation strategies
Conventions: Meta-stylesheets that override this may use the following parameters
generate-paths=true|false generate the @location attribute with XPaths
diagnose= yes | no Add the diagnostics to the assertion test in reports
terminate= yes | no Terminate on the first failed assertion or successful report
-->
<!--
XSLT VERSION SUPPORT
XSLT 1:
A schema using the standard XSLT 1 query binding will have a /schema/@queryBinding='xslt' or
nothing.
* Note: XT does not implement key() and will die if given it.
* Add all formal parameters to default templates
* Fix missing apply-templates from process-ns and add params back
EXSLT: Experimental support
A schema using the EXSLT query binding will have a /schema/@queryBinding='exslt'.
It is built on XSLT 1. After experience is gained, this binding is expected to be
formalized as part of ISO Schematron, which currently reserves the "exslt" name for this purpose.
Some EXSLT engines have the extra functions built-in. For these, there is no need to
provide library locations. For engines that require the functions, either hard code
them in this script or provide them on the command-line argument.
-->
<!--
PROCESS INFORMATION
This stylesheet compiles a Schematron schema (*.sch) into XSLT code (*.xsl).
The generated XSLT code can then be run against an XML file (*.xml, etc) and
will produce validation results.
The output of validation results is performed using named templates (process-*).
These can be overridden easily by making a new XSLT stylesheet that imports this
stylesheet but has its own version of the relevant process-* templates. Several
of these invoking stylesheets are available: "iso_svrl.xsl", for example generates
ISO Schematron Validation Report Language format results.
In this version of the stylesheet, the ISO feature called "abstract patterns" is
implemented using macro processing: a prior XSLT stage to which converts uses
of abstract patterns into normal patterns. If you do not use abstract patterns,
it is not necessary to preprocess the schema.
To summarize, a basic process flow for some commandline processor is like this:
XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_schematron_skeleton.xsl
XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
iso_svrl.xslt is an implementation of Schematron that can use this skeleton and
generate ISO SVRL reports. A process flow for some commandline processor would
be like this:
XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_svrl.xsl
XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
It is not impossible that ultimately a third stage, to handle macro-preprocessing
and inclusion, might be necessary. (The trade-off is in making this XSLT more
complex compared to making the outer process more complex.)
This version has so far been tested with
Saxon 8
MSXML 4 (or 6?)
Please note that if you are using SAXON and JAXP, then you should use
System.setProperty("javax.xml.transform.TransformerFactory",
"net.sf.saxon.TransformerFactoryImpl");
rather than
System.setProperty("javax.xml.xpath.TransformerFactory",
"net.sf.saxon.TransformerFactoryImpl");
which is does not work, at least for the versions of SAXON we tried.
-->
<!--
LEGAL INFORMATION
Copyright (c) 2000-2008 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from
the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
-->
<!--
NOTE: Compared to the iso_schematron_skeleton_for_saxon.xsl code, this version is currently missing
1) localization
2) properties
3) pattern/@documents
VERSION INFORMATION
2009-02-25 RJ
* Fix up variable names so none are used twice in same template
* Tested on SAXON 9, Xalan 2.7.1. Partly tested MSXML.
2008-09-19 RJ
* Add mode schematron-select-full-path and param full-path-notation
2008-08-11
* TT report/@flag was missing
2008-08-06
* TT Top-level lets need to be implemented using xsl:param not xsl:variable
* TT xsl:param/@select must have XPath or not be specified
Version: 2008-07-28
* KH schematron-get-full-path-3 has [index] even on top step
* RJ fix schematron-get-full-path to have namespace predicate, I don't know why this was removed
Version: 2008-07-24
* RJ clean out commented out namespace handling code
* RJ add support for experimental non-standard attribute report/@action
and assert/@action, and add parameter not in the published API (should
not break anything, it is XSLT1)
* RJ Remove remaining XSLT2 code for ease of reading
Version: 2008-07-14 minor update for inclusion experiments
* RJ Clean up zero-length fragment test on include
* RJ Add experimental support for include containers
* RJ For path generation, test for //iso:schema not just /iso:schema, for potential embedded Schematron support
* RJ Don't generate double error messages for old namespace elements
* RJ Experimental iso:rule/iso:title just kept as comment (bigger request Uche Ogbuji)
* RJ Remove spurious debug messages
* RJ Fix bug that prevented including patterns in this (report Roger
Costello)
Version: 2007-10-17
From this version on I am forking XSLT2 support to a different version of the script.
This is due to the increasingly horrible state of the namespace handling code as well
as other inconsistencies between the major implementations of different versions.
The intent is that future versions of this will have XSLT2 isms removed and be simplified
to cope with only XSLT1 and EXLST. Note that though this version is called
iso_schematron_skeleton_for_xslt1, the various meta-stylesheets will continue to just call
iso_schematron_skeleton: it is up to you to rename the stylesheet to the one you want to
use.
* RJ fix FULL-PATH problem with attribute names
Version: 2007-07-19
Accept most changes in David Carlisle's fork, but continue as XSLT1 script:
http://dpcarlisle.blogspot.com/search/label/schematron
* DPC Remove "optimize" parameter
* DPC Add autodetecting optimize parameter attribute to skip checking attribute
context
* DPC Add autodetecting optimize parameter only-child-elements turn off checking for
comments and PIs
* DPC (Experimental: NON_STANDARD DANGER!) Add param visit-text to viist text
nodes too for context
* DPC Fix inclusion syntax to allow #
* DPC Priorities count up from 1000 not down from 4000 to allow more rules
* RJ Add new template for titles of schemas, with existing behaviour.
Override process-schema-title for custom processing of title
Version: 2007-04-04
* RJ debug mode param
* RJ alter mixed test to only test mixed branches, so the same document
could have old and new namespaces schemas in it, but each schema must
be distinct, just so as not to overconstrain things.
* KH zero-length include/@href is fatal error, but allow debug mode
* SB add hint on SAXON and JAXP
* DC generate-full-path-1 generates XLST1 code by default
Version: 2007-03-05
* AS Typo for EXSLT randome, improve comment
* KH get-schematron-full-path-2 needs to apply to attributes too
* DP document policy on extensions better
* DC use copy-of not copy for foreign elements
* DC add generate-path-2
* DC don't try to apply templates to attribute axis on attribute nodes, to
stop SAXON warning.
* RJ improve reporting of typos
Version: 2007-02-08
* KH Schematron fullpath implementation: @* handled twice and / missing
* KH Change stylesheetbody from named template to mode to allow implementers more flexibility.
Move process-ns to outside the stylesheet body.
* DP, FG, fix handling of xslt:key
* FG no iso:title/@class
* Experimental optimization 'visit-no-attributes'
* KH Experimental added schematron-get-full-path-2 which gives prefixed version for humans
* DC Move stylesheet/@version generation to after namespace handling
* DC, FG EXSLT namespace handling code
* FG add ref and commented code from FG's page on namespaces
* Start adding normalize-space() to parameter code
* Add a space between diagnostics
Version: 2007-01-22
* DP change = ($start) to = $start and =($phase) to =$phase
to run under Saxon 8.8j
* FG better title section using ( @id | sch:title)[last()]
* Default query language binding is "xslt" not "xslt1"
Version: 2007-01-19
* Simplify message newline code
* Remove termination and xpath appending to message options:
factor out as iso_schematron_terminator.xsl
* Comment out XSLT2 namespace fix temporarily
Version: 2007-01-18 (First beta candidate for comment)
* DC remove xml:space="preserve"
* FG improve comment on import statement
* DC improve comments on invocation section
* Add exploratory support for sch:schema[@queryBinding='xpath']
by allowing it and warning as lets are found
* Be strict about queryBinding spelling errors
* Extra comments on the different queryBindings
* KH Add option "message-paths" to generate XPath from output
* KH Add option "terminate" to halt with an error after the first assertion
* KH refactor paths in schematron-full-path
* Improve (?) namespace handling: no dummy attributes for prefix "xsl" generated
Version: 2007-01-15
* FG fix for calling templates
* Add formal parameters to default templates: may help XSLT 2
* Fix get-schematron-full-path
* Include skeleton1-6 is commented out by default
Version:2007-01-12 (Pre-beta release to Schematron-love-in maillist)
* Add many extra parameters to the process-* calls, so that almost
all the information in the schema can be provided to client programs.
Also, rearrange the parameters to fit in with the ISO schema, which
has "rich" and "linkable" attribute groups.
* Warn on diagnostics with no ID once only
* Improved path reporting, to handle for namespaces
* Add process-title dummy template for API
* Add command-line parameter allow-foreign (true|false) to suppress
warnings one foreign elements and pass them through to the generated
stylesheet
* remove legacy templates for the old ASCC namespace and no namespace,
and use an import statement instead. Much cleaner now!
* patterns use @id not @name
* titles can contain sub-elements
* start change sch:rule to allow attributes, PIs and comments
* the default process-* for inline elements add a leading and trailing
space, to reduce the chance of concatenation.
* add comments to make the generated code clearer
Version:2006-11-07 (ISO: first release private to schematron-love-in maillist for review)
* Duplicate pattern templates, for handling ISO namespace
* Add priority onto default and paragraph templates
* Add namespace checks
* Handle key in xsl namespace not iso
* Add include
* Improve namespace handling
* Preliminary XSLT2 and EXSLT support
* Refactor iso:schema for clarity
Version: 2003-05-26
* Fix bug with key
Version: 2003-04-16
* handle 1.6 let expressions
* make key use XSLT names, and allow anywhere
Version: 2001-06-13
* same skeleton now supports namespace or no namespace
* parameters to handlers updated for all 1.5 attributes
* diagnostic hints supported: command-line option diagnose=yes|no
Loading ...