You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
3.1 KiB

4 years ago
  1. ISO SCHEMATRON 2009
  2. XSLT implementation by Rick Jelliffe with assistance from members of Schematron-love-in maillist.
  3. 2009-03-18
  4. Two distributions are available. One is for XSLT1 engines.
  5. The other is for XSLT2 engines, such as SAXON 9.
  6. This version of Schematron splits the process into a pipeline of several different XSLT stages.
  7. 1) First, preprocess your Schematron schema with iso_dsdl_include.xsl.
  8. This is a macro processor to assemble the schema from various parts.
  9. If your schema is not in separate parts, you can skip this stage.
  10. 2) Second, preprocess the output from stage 1 with iso_abstract_expand.xsl.
  11. This is a macro processor to convert abstract patterns to real patterns.
  12. If your schema does not use abstract patterns, you can skip this
  13. stage.
  14. 3) Third, compile the Schematron schema into an XSLT script.
  15. This will typically use iso_svrl_for_xslt1.xsl or iso_svrl_for_xslt2.xsl
  16. (which in turn invoke iso_schematron_skeleton_for_xslt1.xsl or iso_schematron_skeleton_for_saxon.xsl)
  17. However, other "meta-styleseets" are also in common use; the principle of operation is the same.
  18. If your schema uses Schematron phases, supply these as command line/invocation parameters
  19. to this process.
  20. 4) Fourth, run the script generated by stage 3 against the document being validated.
  21. If you are using the SVRL script, then the output of validation will be an XML document.
  22. If your schema uses Schematron parameters, supply these as command line/invocation parameters
  23. to this process.
  24. The XSLT2 distribution also features several next generation features,
  25. such as validating multiple documents. See the source code for details.
  26. Schematron assertions can be written in any language, of course; the file
  27. sch-messages-en.xhtml contains the diagnostics messages from the XSLT2 skeleton
  28. in English, and this can be used as template to localize the skeleton's
  29. error messages. Note that typically programming errors in Schematron are XPath
  30. errors, which requires localized messages from the XSLT engine.
  31. ANT
  32. ---
  33. To give an example of how to process a document, here is a sample ANT task.
  34. <target name="schematron-compile-test" >
  35. <!-- expand inclusions -->
  36. <xslt basedir="test/schematron"
  37. style="iso_dsdl_include.xsl" in="test.sch" out="test1.sch">
  38. <classpath>
  39. <pathelement location="${lib.dir}/saxon9.jar"/>
  40. </classpath>
  41. </xslt>
  42. <!-- expand abstract patterns -->
  43. <xslt basedir="test/schematron"
  44. style="iso_abstract_expand.xsl" in="test1.sch" out="test2.sch">
  45. <classpath>
  46. <pathelement location="${lib.dir}/saxon9.jar"/>
  47. </classpath>
  48. </xslt>
  49. <!-- compile it -->
  50. <xslt basedir="test/schematron"
  51. style="iso_svrl_for_xslt2.xsl" in="test2.sch" out="test.xsl">
  52. <classpath>
  53. <pathelement location="${lib.dir}/saxon9.jar"/>
  54. </classpath>
  55. </xslt>
  56. <!-- validate -->
  57. <xslt basedir="test/schematron"
  58. style="test.xsl" in="instance.xml" out="instance.svrlt">
  59. <classpath>
  60. <pathelement location="${lib.dir}/saxon9.jar"/>
  61. </classpath>
  62. </xslt>
  63. </target>