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.

1796 lines
70 KiB

4 years ago
  1. <?xml version="1.0"?><?xar XSLT?>
  2. <!--
  3. OVERVIEW
  4. ASCC/Schematron.com Skeleton Module for ISO Schematron (for XSLT1 systems)
  5. ISO Schematron is a language for making assertion about the presence or absence
  6. of patterns in XML documents. It is typically used for as a schema language, or
  7. to augment existing schema languages, and to check business rules. It is very
  8. powerful, yet quite simple: a developer only need know XPath and about five other
  9. elements.
  10. This is an open source implementation of ISO Schematron in XSLT. Although ISO does
  11. not allow reference implementations which might compete with the text of the
  12. standard, this code has been compiled by Rick Jelliffe, inventor of Schematron
  13. and editor of the ISO standard; so developers can certainly use it as an
  14. unofficial reference implementation for clarification.
  15. This implementation is based on one by Oliver Becker. API documentation is
  16. available separately; try www.schematron.com for this. Funding for this
  17. stylesheet over the years has come from Topologi Pty. Ltd., Geotempo Ltd.,
  18. and ASCC, Tapei.
  19. There are two versions of this skeleton: one is tailored for XSLT1 processors
  20. and the other is tailored for XSLT2 processors. Future versions of the
  21. XSLT2 skeleton may support more features than that the XSLT 1 skeleton.
  22. -->
  23. <!--
  24. TIPS
  25. A tip for new users of Schematron: make your assertions contain positive messages
  26. about what is expected, rather than error messages. For example, use the form
  27. "An X should have a Y, because Z".
  28. Another tip is that Schematron provides an
  29. element <sch:ns> for declaring the namespaces and prefixes used in Xpaths in
  30. attribute values; it does not extend the XML Namespaces mechanism: if a name
  31. in an XPath has a prefix, there must be an <sch:ns> element for that prefix; if
  32. a name in an XPath does not have a prefix, it is always in no namespace.
  33. A tip for implementers of Schematron, either using this API or re-implementing it:
  34. make the value of the diagnostics, flags and richer features available if possible;
  35. Schematron has many of the optional richer features which, if implemented, provide
  36. a compelling alternative approach to validation and business-rules checking compared
  37. to other schema languages and programs.
  38. If you create your own meta-stylesheet to override this one, it is a
  39. good idea to have both in the same directory and to run the stylesheet
  40. from that directory, as many XSLT implementations have ideosyncratic
  41. handling of URLs: keep it simple.
  42. -->
  43. <!--
  44. INVOCATION INFORMATION
  45. The following parameters are available
  46. phase NMTOKEN | "#ALL" (default) Select the phase for validation
  47. allow-foreign "true" | "false" (default) Pass non-Schematron elements to the generated stylesheet
  48. sch.exslt.imports semi-colon delimited string of filenames for some EXSLT implementations
  49. message-newline "true" (default) | "false" Generate an extra newline at the end of messages
  50. optimize "visit-no-attributes"
  51. debug "true" | "false" (default) Debug mode lets compilation continue despite problems
  52. attributes "true" | "false" (Autodetecting) Use only when the schema has no attributes as the context nodes
  53. only-child-elements "true" | "false" (Autodetecting) Use only when the schema has no comments
  54. or PI as the context nodes
  55. The following parameters can be specified as Schematron variables in diagnostics, assertions and so on.
  56. fileNameParameter string
  57. fileDirParameter string
  58. archiveNameParameter string In case of ZIP files
  59. archiveDirParameter string In case of ZIP files
  60. output-encoding Use when outputting to XML
  61. Experimental: USE AT YOUR OWN RISK
  62. visit-text "true" "false" Also visist text nodes for context. WARNING: NON_STARDARD.
  63. select-contents '' | 'key' | '//' Select different implementation strategies
  64. Conventions: Meta-stylesheets that override this may use the following parameters
  65. generate-paths=true|false generate the @location attribute with XPaths
  66. diagnose= yes | no Add the diagnostics to the assertion test in reports
  67. terminate= yes | no Terminate on the first failed assertion or successful report
  68. -->
  69. <!--
  70. XSLT VERSION SUPPORT
  71. XSLT 1:
  72. A schema using the standard XSLT 1 query binding will have a /schema/@queryBinding='xslt' or
  73. nothing.
  74. * Note: XT does not implement key() and will die if given it.
  75. * Add all formal parameters to default templates
  76. * Fix missing apply-templates from process-ns and add params back
  77. EXSLT: Experimental support
  78. A schema using the EXSLT query binding will have a /schema/@queryBinding='exslt'.
  79. It is built on XSLT 1. After experience is gained, this binding is expected to be
  80. formalized as part of ISO Schematron, which currently reserves the "exslt" name for this purpose.
  81. Some EXSLT engines have the extra functions built-in. For these, there is no need to
  82. provide library locations. For engines that require the functions, either hard code
  83. them in this script or provide them on the command-line argument.
  84. -->
  85. <!--
  86. PROCESS INFORMATION
  87. This stylesheet compiles a Schematron schema (*.sch) into XSLT code (*.xsl).
  88. The generated XSLT code can then be run against an XML file (*.xml, etc) and
  89. will produce validation results.
  90. The output of validation results is performed using named templates (process-*).
  91. These can be overridden easily by making a new XSLT stylesheet that imports this
  92. stylesheet but has its own version of the relevant process-* templates. Several
  93. of these invoking stylesheets are available: "iso_svrl.xsl", for example generates
  94. ISO Schematron Validation Report Language format results.
  95. In this version of the stylesheet, the ISO feature called "abstract patterns" is
  96. implemented using macro processing: a prior XSLT stage to which converts uses
  97. of abstract patterns into normal patterns. If you do not use abstract patterns,
  98. it is not necessary to preprocess the schema.
  99. To summarize, a basic process flow for some commandline processor is like this:
  100. XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_schematron_skeleton.xsl
  101. XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
  102. iso_svrl.xslt is an implementation of Schematron that can use this skeleton and
  103. generate ISO SVRL reports. A process flow for some commandline processor would
  104. be like this:
  105. XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_svrl.xsl
  106. XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
  107. It is not impossible that ultimately a third stage, to handle macro-preprocessing
  108. and inclusion, might be necessary. (The trade-off is in making this XSLT more
  109. complex compared to making the outer process more complex.)
  110. This version has so far been tested with
  111. Saxon 8
  112. MSXML 4 (or 6?)
  113. Please note that if you are using SAXON and JAXP, then you should use
  114. System.setProperty("javax.xml.transform.TransformerFactory",
  115. "net.sf.saxon.TransformerFactoryImpl");
  116. rather than
  117. System.setProperty("javax.xml.xpath.TransformerFactory",
  118. "net.sf.saxon.TransformerFactoryImpl");
  119. which is does not work, at least for the versions of SAXON we tried.
  120. -->
  121. <!--
  122. LEGAL INFORMATION
  123. Copyright (c) 2000-2008 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
  124. This software is provided 'as-is', without any express or implied warranty.
  125. In no event will the authors be held liable for any damages arising from
  126. the use of this software.
  127. Permission is granted to anyone to use this software for any purpose,
  128. including commercial applications, and to alter it and redistribute it freely,
  129. subject to the following restrictions:
  130. 1. The origin of this software must not be misrepresented; you must not claim
  131. that you wrote the original software. If you use this software in a product,
  132. an acknowledgment in the product documentation would be appreciated but is
  133. not required.
  134. 2. Altered source versions must be plainly marked as such, and must not be
  135. misrepresented as being the original software.
  136. 3. This notice may not be removed or altered from any source distribution.
  137. -->
  138. <!--
  139. NOTE: Compared to the iso_schematron_skeleton_for_saxon.xsl code, this version is currently missing
  140. 1) localization
  141. 2) properties
  142. 3) pattern/@documents
  143. VERSION INFORMATION
  144. 2009-02-25 RJ
  145. * Fix up variable names so none are used twice in same template
  146. * Tested on SAXON 9, Xalan 2.7.1. Partly tested MSXML.
  147. 2008-09-19 RJ
  148. * Add mode schematron-select-full-path and param full-path-notation
  149. 2008-08-11
  150. * TT report/@flag was missing
  151. 2008-08-06
  152. * TT Top-level lets need to be implemented using xsl:param not xsl:variable
  153. * TT xsl:param/@select must have XPath or not be specified
  154. Version: 2008-07-28
  155. * KH schematron-get-full-path-3 has [index] even on top step
  156. * RJ fix schematron-get-full-path to have namespace predicate, I don't know why this was removed
  157. Version: 2008-07-24
  158. * RJ clean out commented out namespace handling code
  159. * RJ add support for experimental non-standard attribute report/@action
  160. and assert/@action, and add parameter not in the published API (should
  161. not break anything, it is XSLT1)
  162. * RJ Remove remaining XSLT2 code for ease of reading
  163. Version: 2008-07-14 minor update for inclusion experiments
  164. * RJ Clean up zero-length fragment test on include
  165. * RJ Add experimental support for include containers
  166. * RJ For path generation, test for //iso:schema not just /iso:schema, for potential embedded Schematron support
  167. * RJ Don't generate double error messages for old namespace elements
  168. * RJ Experimental iso:rule/iso:title just kept as comment (bigger request Uche Ogbuji)
  169. * RJ Remove spurious debug messages
  170. * RJ Fix bug that prevented including patterns in this (report Roger
  171. Costello)
  172. Version: 2007-10-17
  173. From this version on I am forking XSLT2 support to a different version of the script.
  174. This is due to the increasingly horrible state of the namespace handling code as well
  175. as other inconsistencies between the major implementations of different versions.
  176. The intent is that future versions of this will have XSLT2 isms removed and be simplified
  177. to cope with only XSLT1 and EXLST. Note that though this version is called
  178. iso_schematron_skeleton_for_xslt1, the various meta-stylesheets will continue to just call
  179. iso_schematron_skeleton: it is up to you to rename the stylesheet to the one you want to
  180. use.
  181. * RJ fix FULL-PATH problem with attribute names
  182. Version: 2007-07-19
  183. Accept most changes in David Carlisle's fork, but continue as XSLT1 script:
  184. http://dpcarlisle.blogspot.com/search/label/schematron
  185. * DPC Remove "optimize" parameter
  186. * DPC Add autodetecting optimize parameter attribute to skip checking attribute
  187. context
  188. * DPC Add autodetecting optimize parameter only-child-elements turn off checking for
  189. comments and PIs
  190. * DPC (Experimental: NON_STANDARD DANGER!) Add param visit-text to viist text
  191. nodes too for context
  192. * DPC Fix inclusion syntax to allow #
  193. * DPC Priorities count up from 1000 not down from 4000 to allow more rules
  194. * RJ Add new template for titles of schemas, with existing behaviour.
  195. Override process-schema-title for custom processing of title
  196. Version: 2007-04-04
  197. * RJ debug mode param
  198. * RJ alter mixed test to only test mixed branches, so the same document
  199. could have old and new namespaces schemas in it, but each schema must
  200. be distinct, just so as not to overconstrain things.
  201. * KH zero-length include/@href is fatal error, but allow debug mode
  202. * SB add hint on SAXON and JAXP
  203. * DC generate-full-path-1 generates XLST1 code by default
  204. Version: 2007-03-05
  205. * AS Typo for EXSLT randome, improve comment
  206. * KH get-schematron-full-path-2 needs to apply to attributes too
  207. * DP document policy on extensions better
  208. * DC use copy-of not copy for foreign elements
  209. * DC add generate-path-2
  210. * DC don't try to apply templates to attribute axis on attribute nodes, to
  211. stop SAXON warning.
  212. * RJ improve reporting of typos
  213. Version: 2007-02-08
  214. * KH Schematron fullpath implementation: @* handled twice and / missing
  215. * KH Change stylesheetbody from named template to mode to allow implementers more flexibility.
  216. Move process-ns to outside the stylesheet body.
  217. * DP, FG, fix handling of xslt:key
  218. * FG no iso:title/@class
  219. * Experimental optimization 'visit-no-attributes'
  220. * KH Experimental added schematron-get-full-path-2 which gives prefixed version for humans
  221. * DC Move stylesheet/@version generation to after namespace handling
  222. * DC, FG EXSLT namespace handling code
  223. * FG add ref and commented code from FG's page on namespaces
  224. * Start adding normalize-space() to parameter code
  225. * Add a space between diagnostics
  226. Version: 2007-01-22
  227. * DP change = ($start) to = $start and =($phase) to =$phase
  228. to run under Saxon 8.8j
  229. * FG better title section using ( @id | sch:title)[last()]
  230. * Default query language binding is "xslt" not "xslt1"
  231. Version: 2007-01-19
  232. * Simplify message newline code
  233. * Remove termination and xpath appending to message options:
  234. factor out as iso_schematron_terminator.xsl
  235. * Comment out XSLT2 namespace fix temporarily
  236. Version: 2007-01-18 (First beta candidate for comment)
  237. * DC remove xml:space="preserve"
  238. * FG improve comment on import statement
  239. * DC improve comments on invocation section
  240. * Add exploratory support for sch:schema[@queryBinding='xpath']
  241. by allowing it and warning as lets are found
  242. * Be strict about queryBinding spelling errors
  243. * Extra comments on the different queryBindings
  244. * KH Add option "message-paths" to generate XPath from output
  245. * KH Add option "terminate" to halt with an error after the first assertion
  246. * KH refactor paths in schematron-full-path
  247. * Improve (?) namespace handling: no dummy attributes for prefix "xsl" generated
  248. Version: 2007-01-15
  249. * FG fix for calling templates
  250. * Add formal parameters to default templates: may help XSLT 2
  251. * Fix get-schematron-full-path
  252. * Include skeleton1-6 is commented out by default
  253. Version:2007-01-12 (Pre-beta release to Schematron-love-in maillist)
  254. * Add many extra parameters to the process-* calls, so that almost
  255. all the information in the schema can be provided to client programs.
  256. Also, rearrange the parameters to fit in with the ISO schema, which
  257. has "rich" and "linkable" attribute groups.
  258. * Warn on diagnostics with no ID once only
  259. * Improved path reporting, to handle for namespaces
  260. * Add process-title dummy template for API
  261. * Add command-line parameter allow-foreign (true|false) to suppress
  262. warnings one foreign elements and pass them through to the generated
  263. stylesheet
  264. * remove legacy templates for the old ASCC namespace and no namespace,
  265. and use an import statement instead. Much cleaner now!
  266. * patterns use @id not @name
  267. * titles can contain sub-elements
  268. * start change sch:rule to allow attributes, PIs and comments
  269. * the default process-* for inline elements add a leading and trailing
  270. space, to reduce the chance of concatenation.
  271. * add comments to make the generated code clearer
  272. Version:2006-11-07 (ISO: first release private to schematron-love-in maillist for review)
  273. * Duplicate pattern templates, for handling ISO namespace
  274. * Add priority onto default and paragraph templates
  275. * Add namespace checks
  276. * Handle key in xsl namespace not iso
  277. * Add include
  278. * Improve namespace handling
  279. * Preliminary XSLT2 and EXSLT support
  280. * Refactor iso:schema for clarity
  281. Version: 2003-05-26
  282. * Fix bug with key
  283. Version: 2003-04-16
  284. * handle 1.6 let expressions
  285. * make key use XSLT names, and allow anywhere
  286. Version: 2001-06-13
  287. * same skeleton now supports namespace or no namespace
  288. * parameters to handlers updated for all 1.5 attributes
  289. * diagnostic hints supported: command-line option diagnose=yes|no
  290. * phases supported: command-line option phase=#ALL|...
  291. * abstract rules
  292. * compile-time error messages
  293. * add utility routine generate-id-from-path
  294. Contributors: Rick Jelliffe (original), Oliver Becker (architecture, XSLT2),
  295. Miloslav Nic (diagnostic, phase, options), Ludwig Svenonius (abstract)
  296. Uche Ogbuji (misc. bug fixes), Jim Ancona (SAXON workaround),
  297. Francis Norton (generate-id-from-path), Robert Leftwich, Bryan Rasmussen,
  298. Dave Pawson (include, fallback), Florent Georges (namespaces, exslt, attribute
  299. context), Benoit Maisonny (attribute context), John Dumps (process-message newline),
  300. Cliff Stanford (diagnostics and other newlines)
  301. KNOWN TYPICAL LIMITATIONS:
  302. * Don't use <sch:ns prefix="xsl" .../> with a namespace other than the standard
  303. XSLT one. This would be a bizarre thing to do anyway.
  304. * Don't use other prefixes for the XSLT namespace either; some implementations will
  305. not handle it correctly.
  306. EXTENSIONS:
  307. ISO Schematron is designed as a framework with some standard query language
  308. bindings. If you need to support other features, please do so safely by making
  309. up your own @queryLanguage name: this makes it clear that your schema requires
  310. special features. For example, default ISO Schematron does not support user
  311. defined functions; so if you want to use the user defined function feature
  312. in XSLT, you need to have a schema with some queryBinding attribute name like
  313. "XSLT-with-my-functions" or whatever.
  314. -->
  315. <xsl:stylesheet version="1.0"
  316. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  317. xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
  318. xmlns:sch="http://www.ascc.net/xml/schematron"
  319. xmlns:iso="http://purl.oclc.org/dsdl/schematron"
  320. xmlns:exsl="http://exslt.org/common"
  321. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  322. extension-element-prefixes="exsl msxsl"
  323. >
  324. <!-- This program implements ISO Schematron, except for abstract patterns which require a preprocess. -->
  325. <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
  326. <!-- Category: top-level-element -->
  327. <xsl:output method="xml" omit-xml-declaration="no" standalone="yes" indent="yes"/>
  328. <xsl:param name="phase">
  329. <xsl:choose>
  330. <xsl:when test="//sch:schema/@defaultPhase">
  331. <xsl:value-of select="//sch:schema/@defaultPhase"/>
  332. </xsl:when>
  333. <xsl:when test="//iso:schema/@defaultPhase">
  334. <xsl:value-of select="//iso:schema/@defaultPhase"/>
  335. </xsl:when>
  336. <xsl:otherwise>#ALL</xsl:otherwise>
  337. </xsl:choose>
  338. </xsl:param>
  339. <xsl:param name="allow-foreign">false</xsl:param>
  340. <xsl:param name="message-newline">true</xsl:param>
  341. <!-- DPC set to true if contexts should be checked on attribute nodes
  342. defaults to true if there is any possibility that a context could match an attribute,
  343. err on the side if caution, a context of *[.='@'] would cause this param to defualt to true
  344. even though @ is in a string
  345. -->
  346. <xsl:param name="attributes">
  347. <xsl:choose>
  348. <xsl:when test="//iso:rule[contains(@context,'@') or contains(@context,'attribute')]">true</xsl:when>
  349. <xsl:otherwise>false</xsl:otherwise>
  350. </xsl:choose>
  351. </xsl:param>
  352. <!-- DPC set to true if contexts should be checked on just elements in the child axis
  353. defaults to true if there is any possibility that a context could match an comment or PI
  354. err on the side if caution, a context of *[.='('] would cause this param to defualt to true
  355. even though ( is in a string, but node() comment() and processing-instruction() all have a (
  356. -->
  357. <xsl:param name="only-child-elements">
  358. <xsl:choose>
  359. <xsl:when test="//iso:rule[contains(@context,'(')]">true</xsl:when>
  360. <xsl:otherwise>false</xsl:otherwise>
  361. </xsl:choose>
  362. </xsl:param>
  363. <!-- DPC set to true if contexts should be checked on text nodes nodes (if only-child-elements is false)
  364. THIS IS NON CONFORMANT BEHAVIOUR JUST FOR DISCUSSION OF A POSSIBLE CHANGE TO THE
  365. SPECIFICATION. THIS PARAM SHOULD GO IF THE FINAL DECISION IS THAT THE SPEC DOES NOT CHANGE.
  366. Always defaults to false
  367. -->
  368. <xsl:param name="visit-text" select="'false'"/>
  369. <!-- DPC
  370. When selecting contexts the specified behaviour is
  371. @*|node()[not(self::text())]
  372. The automatic settings may use
  373. node()[not(self::text())]
  374. @*|*
  375. *
  376. instead for schema for which they are equivalent.
  377. If the params are set explictly the above may be used, and also either if
  378. @*
  379. @*|node()
  380. in all cases the result may not be equivalent, for example if you specify no attributes and the schema
  381. does have attribute contexts they will be silently ignored.
  382. after testing it turns out that
  383. node()[not(self::text())] is slower in saxon than *|comment()|processing-instruction()
  384. which I find a bit surprising but anyway I'll use the longr faster version.
  385. -->
  386. <xsl:variable name="context-xpath">
  387. <xsl:if test="$attributes='true'">@*|</xsl:if>
  388. <xsl:choose>
  389. <xsl:when test="$only-child-elements='true'">*</xsl:when>
  390. <xsl:when test="$visit-text='true'">node()</xsl:when>
  391. <xsl:otherwise>*|comment()|processing-instruction()</xsl:otherwise>
  392. </xsl:choose>
  393. </xsl:variable>
  394. <!-- DPC if this is set to
  395. '' use recursive templates to iterate over document tree,
  396. 'key' select all contexts with a key rather than walking the tree explictly in each mode
  397. '//' select all contexts with // a key rather than walking the tree explictly in each mode (XSLT2 only)
  398. -->
  399. <xsl:param name="select-contexts" select="''"/>
  400. <xsl:param name="output-encoding"/>
  401. <!-- e.g. saxon file.xml file.xsl "sch.exslt.imports=.../string.xsl;.../math.xsl" -->
  402. <xsl:param name="sch.exslt.imports"/>
  403. <!-- Set the language code for messages -->
  404. <xsl:param name="langCode">default</xsl:param>
  405. <xsl:param name="debug">false</xsl:param>
  406. <!-- Set the default for schematron-select-full-path, i.e. the notation for svrl's @location-->
  407. <xsl:param name="full-path-notation">1</xsl:param>
  408. <!-- Simple namespace check -->
  409. <xsl:template match="/">
  410. <xsl:if test="//sch:*[ancestor::iso:* or descendant::iso:*]">
  411. <xsl:message>Schema error: Schematron elements in old and new namespaces found</xsl:message>
  412. <xsl:if test=" $debug = 'false' " />
  413. </xsl:if>
  414. <xsl:apply-templates />
  415. </xsl:template>
  416. <!-- ============================================================== -->
  417. <!-- ISO SCHEMATRON SCHEMA ELEMENT -->
  418. <!-- Not handled: Abstract patterns. A pre-processor is assumed. -->
  419. <!-- ============================================================== -->
  420. <!-- SCHEMA -->
  421. <!-- Default uses XSLT 1 -->
  422. <xsl:template match="iso:schema[not(@queryBinding) or @queryBinding='xslt'
  423. or @queryBinding='xslt1' or @queryBinding='XSLT' or @queryBinding='XSLT1'
  424. or @queryBinding='xpath']">
  425. <xsl:if test="
  426. @queryBinding='xslt1' or @queryBinding='XSLT' or @queryBinding='XSLT1'">
  427. <xsl:message>Schema error: in the queryBinding attribute, use 'xslt'</xsl:message>
  428. </xsl:if>
  429. <axsl:stylesheet>
  430. <xsl:apply-templates select="iso:ns"/>
  431. <!-- Handle the namespaces before the version attribute: reported to help SAXON -->
  432. <xsl:attribute name="version">1.0</xsl:attribute>
  433. <xsl:apply-templates select="." mode="stylesheetbody"/>
  434. <!-- was xsl:call-template name="stylesheetbody"/ -->
  435. </axsl:stylesheet>
  436. </xsl:template>
  437. <!-- Using EXSLT with all modeles (except function module: not applicable) -->
  438. <xsl:template match="iso:schema[@queryBinding='exslt']" priority="10">
  439. <xsl:comment>This XSLT was automatically generated from a Schematron schema.</xsl:comment>
  440. <axsl:stylesheet
  441. xmlns:date="http://exslt.org/dates-and-times"
  442. xmlns:dyn="http://exslt.org/dynamic"
  443. xmlns:exsl="http://exslt.org/common"
  444. xmlns:math="http://exslt.org/math"
  445. xmlns:random="http://exslt.org/random"
  446. xmlns:regexp="http://exslt.org/regular-expressions"
  447. xmlns:set="http://exslt.org/sets"
  448. xmlns:str="http://exslt.org/strings"
  449. extension-element-prefixes="date dyn exsl math random regexp set str" >
  450. <xsl:apply-templates select="iso:ns"/>
  451. <!-- Handle the namespaces before the version attribute: reported to help SAXON -->
  452. <xsl:attribute name="version">1.0</xsl:attribute>
  453. <xsl:apply-templates select="." mode="stylesheetbody"/>
  454. <!-- was xsl:call-template name="stylesheetbody"/ -->
  455. </axsl:stylesheet>
  456. </xsl:template>
  457. <!-- Default uses XSLT 1 -->
  458. <xsl:template match="iso:schema" priority="-1">
  459. <xsl:message terminate="yes" >Fail: This implementation of ISO Schematron does not work with
  460. schemas using the "<xsl:value-of select="@queryBinding"/>" query language.</xsl:message>
  461. </xsl:template>
  462. <xsl:template match="*" mode="stylesheetbody">
  463. <!--xsl:template name="stylesheetbody"-->
  464. <xsl:comment>Implementers: please note that overriding process-prolog or process-root is
  465. the preferred method for meta-stylesheets to use where possible. </xsl:comment><xsl:text>&#10;</xsl:text>
  466. <!-- These parameters may contain strings with the name and directory of the file being
  467. validated. For convenience, if the caller only has the information in a single string,
  468. that string could be put in fileDirParameter. The archives parameters are available
  469. for ZIP archives.
  470. -->
  471. <axsl:param name="archiveDirParameter" />
  472. <axsl:param name="archiveNameParameter" />
  473. <axsl:param name="fileNameParameter" />
  474. <axsl:param name="fileDirParameter" />
  475. <xsl:call-template name="iso:exslt.add.imports" />
  476. <xsl:text>&#10;&#10;</xsl:text><xsl:comment>PHASES</xsl:comment><xsl:text>&#10;</xsl:text>
  477. <xsl:call-template name="handle-phase"/>
  478. <xsl:text>&#10;&#10;</xsl:text><xsl:comment>PROLOG</xsl:comment><xsl:text>&#10;</xsl:text>
  479. <xsl:call-template name="process-prolog"/>
  480. <xsl:text>&#10;&#10;</xsl:text><xsl:comment>KEYS</xsl:comment><xsl:text>&#10;</xsl:text>
  481. <xsl:apply-templates mode="do-keys" select="xsl:key "/>
  482. <xsl:text>&#10;&#10;</xsl:text><xsl:comment>DEFAULT RULES</xsl:comment><xsl:text>&#10;</xsl:text>
  483. <xsl:call-template name="generate-default-rules" />
  484. <xsl:text>&#10;&#10;</xsl:text><xsl:comment>SCHEMA METADATA</xsl:comment><xsl:text>&#10;</xsl:text>
  485. <xsl:call-template name="handle-root"/>
  486. <xsl:text>&#10;&#10;</xsl:text><xsl:comment>SCHEMATRON PATTERNS</xsl:comment><xsl:text>&#10;</xsl:text>
  487. <xsl:apply-templates select="*[not(self::iso:ns)] " />
  488. </xsl:template>
  489. <xsl:template name="iso:exslt.add.imports">
  490. <xsl:param name="imports" select="$sch.exslt.imports"/>
  491. <xsl:choose>
  492. <xsl:when test="contains($imports, ';')">
  493. <axsl:import href="{ substring-before($imports, ';') }"/>
  494. <xsl:call-template name="iso:exslt.add.imports">
  495. <xsl:with-param name="imports" select="substring-after($imports, ';')"/>
  496. </xsl:call-template>
  497. </xsl:when>
  498. <xsl:when test="$imports">
  499. <axsl:import href="{ $imports }"/>
  500. </xsl:when>
  501. </xsl:choose>
  502. </xsl:template>
  503. <xsl:template name="handle-phase" >
  504. <xsl:if test="not(normalize-space( $phase ) = '#ALL')">
  505. <xsl:if test="not(iso:phase[@id = normalize-space( $phase )])">
  506. <xsl:message>Phase Error: no phase with name <xsl:value-of select="normalize-space( $phase )"
  507. /> has been defined.</xsl:message>
  508. </xsl:if>
  509. </xsl:if>
  510. </xsl:template>
  511. <xsl:template name="generate-default-rules">
  512. <xsl:text>&#10;&#10;</xsl:text>
  513. <xsl:comment>MODE: SCHEMATRON-SELECT-FULL-PATH</xsl:comment><xsl:text>&#10;</xsl:text>
  514. <xsl:comment>This mode can be used to generate an ugly though full XPath for locators</xsl:comment><xsl:text>&#10;</xsl:text>
  515. <axsl:template match="*" mode="schematron-select-full-path">
  516. <xsl:choose>
  517. <xsl:when test=" $full-path-notation = '1' ">
  518. <!-- Use for computers, but rather unreadable for humans -->
  519. <axsl:apply-templates select="." mode="schematron-get-full-path"/>
  520. </xsl:when>
  521. <xsl:when test=" $full-path-notation = '2' ">
  522. <!-- Use for humans, but no good for paths unless namespaces are known out-of-band -->
  523. <axsl:apply-templates select="." mode="schematron-get-full-path-2"/>
  524. </xsl:when>
  525. <xsl:when test=" $full-path-notation = '3' ">
  526. <!-- Obsolescent. Use for humans, but no good for paths unless namespaces are known out-of-band -->
  527. <axsl:apply-templates select="." mode="schematron-get-full-path-3"/>
  528. </xsl:when>
  529. <xsl:otherwise >
  530. <!-- Use for computers, but rather unreadable for humans -->
  531. <axsl:apply-templates select="." mode="schematron-get-full-path"/>
  532. </xsl:otherwise>
  533. </xsl:choose>
  534. </axsl:template>
  535. <xsl:text>&#10;&#10;</xsl:text>
  536. <xsl:comment>MODE: SCHEMATRON-FULL-PATH</xsl:comment><xsl:text>&#10;</xsl:text>
  537. <xsl:comment>This mode can be used to generate an ugly though full XPath for locators</xsl:comment><xsl:text>&#10;</xsl:text>
  538. <axsl:template match="*" mode="schematron-get-full-path">
  539. <axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
  540. <!-- XSLT1 syntax -->
  541. <axsl:text>/</axsl:text>
  542. <axsl:choose>
  543. <axsl:when test="namespace-uri()=''">
  544. <axsl:value-of select="name()"/>
  545. <axsl:variable name="p_1" select="1+
  546. count(preceding-sibling::*[name()=name(current())])" />
  547. <axsl:if test="$p_1&gt;1 or following-sibling::*[name()=name(current())]">
  548. <xsl:text/>[<axsl:value-of select="$p_1"/>]<xsl:text/>
  549. </axsl:if>
  550. </axsl:when>
  551. <axsl:otherwise>
  552. <axsl:text>*[local-name()='</axsl:text>
  553. <axsl:value-of select="local-name()"/><axsl:text>' and namespace-uri()='</axsl:text>
  554. <axsl:value-of select="namespace-uri()"/>
  555. <axsl:text>']</axsl:text>
  556. <axsl:variable name="p_2" select="1+
  557. count(preceding-sibling::*[local-name()=local-name(current())])" />
  558. <axsl:if test="$p_2&gt;1 or following-sibling::*[local-name()=local-name(current())]">
  559. <xsl:text/>[<axsl:value-of select="$p_2"/>]<xsl:text/>
  560. </axsl:if>
  561. </axsl:otherwise>
  562. </axsl:choose>
  563. </axsl:template>
  564. <axsl:template match="@*" mode="schematron-get-full-path">
  565. <!-- XSLT1 syntax -->
  566. <axsl:text>/</axsl:text>
  567. <axsl:choose>
  568. <axsl:when test="namespace-uri()=''">@<axsl:value-of
  569. select="name()"/></axsl:when>
  570. <axsl:otherwise>
  571. <axsl:text>@*[local-name()='</axsl:text>
  572. <axsl:value-of select="local-name()"/>
  573. <axsl:text>' and namespace-uri()='</axsl:text>
  574. <axsl:value-of select="namespace-uri()"/>
  575. <axsl:text>']</axsl:text>
  576. </axsl:otherwise>
  577. </axsl:choose>
  578. </axsl:template>
  579. <xsl:text>&#10;&#10;</xsl:text>
  580. <xsl:comment>MODE: SCHEMATRON-FULL-PATH-2</xsl:comment>
  581. <xsl:text>&#10;</xsl:text>
  582. <xsl:comment>This mode can be used to generate prefixed XPath for humans</xsl:comment>
  583. <xsl:text>&#10;</xsl:text>
  584. <!--simplify the error messages by using the namespace prefixes of the
  585. instance rather than the generic namespace-uri-styled qualification-->
  586. <axsl:template match="node() | @*" mode="schematron-get-full-path-2">
  587. <!--report the element hierarchy-->
  588. <axsl:for-each select="ancestor-or-self::*">
  589. <axsl:text>/</axsl:text>
  590. <axsl:value-of select="name(.)"/>
  591. <axsl:if test="preceding-sibling::*[name(.)=name(current())]">
  592. <axsl:text>[</axsl:text>
  593. <axsl:value-of
  594. select="count(preceding-sibling::*[name(.)=name(current())])+1"/>
  595. <axsl:text>]</axsl:text>
  596. </axsl:if>
  597. </axsl:for-each>
  598. <!--report the attribute-->
  599. <axsl:if test="not(self::*)">
  600. <axsl:text/>/@<axsl:value-of select="name(.)"/>
  601. </axsl:if>
  602. </axsl:template>
  603. <xsl:text>&#10;&#10;</xsl:text>
  604. <xsl:comment>MODE: GENERATE-ID-FROM-PATH </xsl:comment><xsl:text>&#10;</xsl:text>
  605. <!-- repeatable-id maker derived from Francis Norton's. -->
  606. <!-- use this if you need generate ids in separate passes,
  607. because generate-id() is not guaranteed to produce the same
  608. results each time. These ids are not XML names but closer to paths. -->
  609. <axsl:template match="/" mode="generate-id-from-path"/>
  610. <axsl:template match="text()" mode="generate-id-from-path">
  611. <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
  612. <axsl:value-of select="concat('.text-', 1+count(preceding-sibling::text()), '-')"/>
  613. </axsl:template>
  614. <axsl:template match="comment()" mode="generate-id-from-path">
  615. <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
  616. <axsl:value-of select="concat('.comment-', 1+count(preceding-sibling::comment()), '-')"/>
  617. </axsl:template>
  618. <axsl:template match="processing-instruction()" mode="generate-id-from-path">
  619. <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
  620. <axsl:value-of
  621. select="concat('.processing-instruction-', 1+count(preceding-sibling::processing-instruction()), '-')"/>
  622. </axsl:template>
  623. <axsl:template match="@*" mode="generate-id-from-path">
  624. <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
  625. <axsl:value-of select="concat('.@', name())"/>
  626. </axsl:template>
  627. <axsl:template match="*" mode="generate-id-from-path" priority="-0.5">
  628. <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
  629. <axsl:text>.</axsl:text>
  630. <!--
  631. <axsl:choose>
  632. <axsl:when test="count(. | ../namespace::*) = count(../namespace::*)">
  633. <axsl:value-of select="concat('.namespace::-',1+count(namespace::*),'-')"/>
  634. </axsl:when>
  635. <axsl:otherwise>
  636. -->
  637. <axsl:value-of
  638. select="concat('.',name(),'-',1+count(preceding-sibling::*[name()=name(current())]),'-')"/>
  639. <!--
  640. </axsl:otherwise>
  641. </axsl:choose>
  642. -->
  643. </axsl:template>
  644. <xsl:comment>MODE: SCHEMATRON-FULL-PATH-3</xsl:comment>
  645. <xsl:text>&#10;</xsl:text>
  646. <xsl:comment>This mode can be used to generate prefixed XPath for humans
  647. (Top-level element has index)</xsl:comment>
  648. <xsl:text>&#10;</xsl:text>
  649. <!--simplify the error messages by using the namespace prefixes of the
  650. instance rather than the generic namespace-uri-styled qualification-->
  651. <axsl:template match="node() | @*" mode="schematron-get-full-path-3">
  652. <!--report the element hierarchy-->
  653. <axsl:for-each select="ancestor-or-self::*">
  654. <axsl:text>/</axsl:text>
  655. <axsl:value-of select="name(.)"/>
  656. <axsl:if test="parent::*">
  657. <axsl:text>[</axsl:text>
  658. <axsl:value-of
  659. select="count(preceding-sibling::*[name(.)=name(current())])+1"/>
  660. <axsl:text>]</axsl:text>
  661. </axsl:if>
  662. </axsl:for-each>
  663. <!--report the attribute-->
  664. <axsl:if test="not(self::*)">
  665. <axsl:text/>/@<axsl:value-of select="name(.)"/>
  666. </axsl:if>
  667. </axsl:template>
  668. <xsl:text>&#10;&#10;</xsl:text>
  669. <xsl:comment>MODE: GENERATE-ID-2 </xsl:comment><xsl:text>&#10;</xsl:text>
  670. <!-- repeatable-id maker from David Carlisle. -->
  671. <!-- use this if you need generate IDs in separate passes,
  672. because generate-id() is not guaranteed to produce the same
  673. results each time. These IDs are well-formed XML NMTOKENS -->
  674. <axsl:template match="/" mode="generate-id-2">U</axsl:template>
  675. <axsl:template match="*" mode="generate-id-2" priority="2">
  676. <axsl:text>U</axsl:text>
  677. <axsl:number level="multiple" count="*"/>
  678. </axsl:template>
  679. <axsl:template match="node()" mode="generate-id-2">
  680. <axsl:text>U.</axsl:text>
  681. <axsl:number level="multiple" count="*"/>
  682. <axsl:text>n</axsl:text>
  683. <axsl:number count="node()"/>
  684. </axsl:template>
  685. <axsl:template match="@*" mode="generate-id-2">
  686. <axsl:text>U.</axsl:text>
  687. <axsl:number level="multiple" count="*"/>
  688. <axsl:text>_</axsl:text>
  689. <axsl:value-of select="string-length(local-name(.))"/>
  690. <axsl:text>_</axsl:text>
  691. <axsl:value-of select="translate(name(),':','.')"/>
  692. </axsl:template>
  693. <xsl:comment>Strip characters</xsl:comment>
  694. <axsl:template match="text()" priority="-1" />
  695. </xsl:template>
  696. <xsl:template name="handle-root">
  697. <!-- Process the top-level element -->
  698. <axsl:template match="/">
  699. <xsl:call-template name="process-root">
  700. <xsl:with-param
  701. name="title" select="(@id | iso:title)[last()]"/>
  702. <xsl:with-param name="version" select="'iso'" />
  703. <xsl:with-param name="schemaVersion" select="@schemaVersion" />
  704. <xsl:with-param name="queryBinding" select="@queryBinding" />
  705. <xsl:with-param name="contents">
  706. <xsl:apply-templates mode="do-all-patterns"/>
  707. </xsl:with-param>
  708. <!-- "Rich" properties -->
  709. <xsl:with-param name="fpi" select="@fpi"/>
  710. <xsl:with-param name="icon" select="@icon"/>
  711. <xsl:with-param name="id" select="@id"/>
  712. <xsl:with-param name="lang" select="@xml:lang"/>
  713. <xsl:with-param name="see" select="@see" />
  714. <xsl:with-param name="space" select="@xml:space" />
  715. <!-- Non-standard extensions not part of the API yet -->
  716. <xsl:with-param name="action" select="@action" />
  717. </xsl:call-template>
  718. </axsl:template>
  719. </xsl:template>
  720. <!-- ============================================================== -->
  721. <!-- ISO SCHEMATRON ELEMENTS -->
  722. <!-- ============================================================== -->
  723. <!-- ISO ACTIVE -->
  724. <xsl:template match="iso:active">
  725. <xsl:if test="not(@pattern)">
  726. <xsl:message>Markup Error: no pattern attribute in &lt;active></xsl:message>
  727. </xsl:if>
  728. <xsl:if test="not(../../iso:pattern[@id = current()/@pattern])
  729. and not(../../iso:include)">
  730. <xsl:message>Reference Error: the pattern "<xsl:value-of select="@pattern"
  731. />" has been activated but is not declared</xsl:message>
  732. </xsl:if>
  733. </xsl:template>
  734. <!-- ISO ASSERT and REPORT -->
  735. <xsl:template match="iso:assert">
  736. <xsl:if test="not(@test)">
  737. <xsl:message>Markup Error: no test attribute in &lt;assert</xsl:message>
  738. </xsl:if>
  739. <xsl:text>&#10;&#10; </xsl:text>
  740. <xsl:comment>ASSERT <xsl:value-of select="@role" /> </xsl:comment><xsl:text>&#10;</xsl:text>
  741. <axsl:choose>
  742. <axsl:when test="{@test}"/>
  743. <axsl:otherwise>
  744. <xsl:call-template name="process-assert">
  745. <xsl:with-param name="test" select="normalize-space(@test)" />
  746. <xsl:with-param name="diagnostics" select="@diagnostics"/>
  747. <xsl:with-param name="flag" select="@flag"/>
  748. <!-- "Rich" properties -->
  749. <xsl:with-param name="fpi" select="@fpi"/>
  750. <xsl:with-param name="icon" select="@icon"/>
  751. <xsl:with-param name="id" select="@id"/>
  752. <xsl:with-param name="lang" select="@xml:lang"/>
  753. <xsl:with-param name="see" select="@see" />
  754. <xsl:with-param name="space" select="@xml:space" />
  755. <!-- "Linking" properties -->
  756. <xsl:with-param name="role" select="@role" />
  757. <xsl:with-param name="subject" select="@subject" />
  758. </xsl:call-template>
  759. </axsl:otherwise>
  760. </axsl:choose>
  761. </xsl:template>
  762. <xsl:template match="iso:report">
  763. <xsl:if test="not(@test)">
  764. <xsl:message>Markup Error: no test attribute in &lt;report></xsl:message>
  765. </xsl:if>
  766. <xsl:text>&#10;&#10; </xsl:text>
  767. <xsl:comment>REPORT <xsl:value-of select="@role" /> </xsl:comment><xsl:text>&#10;</xsl:text>
  768. <axsl:if test="{@test}">
  769. <xsl:call-template name="process-report">
  770. <xsl:with-param name="test" select="normalize-space(@test)" />
  771. <xsl:with-param name="diagnostics" select="@diagnostics"/>
  772. <xsl:with-param name="flag" select="@flag"/>
  773. <!-- "Rich" properties -->
  774. <xsl:with-param name="fpi" select="@fpi"/>
  775. <xsl:with-param name="icon" select="@icon"/>
  776. <xsl:with-param name="id" select="@id"/>
  777. <xsl:with-param name="lang" select="@xml:lang"/>
  778. <xsl:with-param name="see" select="@see" />
  779. <xsl:with-param name="space" select="@xml:space" />
  780. <!-- "Linking" properties -->
  781. <xsl:with-param name="role" select="@role" />
  782. <xsl:with-param name="subject" select="@subject" />
  783. </xsl:call-template>
  784. </axsl:if>
  785. </xsl:template>
  786. <!-- ISO DIAGNOSTIC -->
  787. <!-- We use a mode here to maintain backwards compatability, instead of adding it
  788. to the other mode.
  789. -->
  790. <xsl:template match="iso:diagnostic" mode="check-diagnostics">
  791. <xsl:if test="not(@id)">
  792. <xsl:message>Markup Error: no id attribute in &lt;diagnostic></xsl:message>
  793. </xsl:if>
  794. </xsl:template>
  795. <xsl:template match="iso:diagnostic" >
  796. <xsl:call-template name="process-diagnostic">
  797. <!-- "Rich" properties -->
  798. <xsl:with-param name="fpi" select="@fpi"/>
  799. <xsl:with-param name="icon" select="@icon"/>
  800. <xsl:with-param name="id" select="@id"/>
  801. <xsl:with-param name="lang" select="@xml:lang"/>
  802. <xsl:with-param name="see" select="@see" />
  803. <xsl:with-param name="space" select="@xml:space" />
  804. </xsl:call-template>
  805. </xsl:template>
  806. <!-- ISO DIAGNOSTICS -->
  807. <xsl:template match="iso:diagnostics" >
  808. <xsl:apply-templates mode="check-diagnostics" select="*" />
  809. </xsl:template>
  810. <!-- ISO DIR -->
  811. <xsl:template match="iso:dir" mode="text" >
  812. <xsl:call-template name="process-dir">
  813. <xsl:with-param name="value" select="@value"/>
  814. </xsl:call-template>
  815. </xsl:template>
  816. <!-- ISO EMPH -->
  817. <xsl:template match="iso:emph" mode="text">
  818. <xsl:call-template name="process-emph"/>
  819. </xsl:template>
  820. <!-- ISO EXTENDS -->
  821. <xsl:template match="iso:extends">
  822. <xsl:if test="not(@rule)">
  823. <xsl:message>Markup Error: no rule attribute in &lt;extends></xsl:message>
  824. </xsl:if>
  825. <xsl:if test="not(//iso:rule[@abstract='true'][@id= current()/@rule] )">
  826. <xsl:message>Reference Error: the abstract rule "<xsl:value-of select="@rule"
  827. />" has been referenced but is not declared</xsl:message>
  828. </xsl:if>
  829. <xsl:call-template name="IamEmpty" />
  830. <xsl:if test="//iso:rule[@id=current()/@rule]">
  831. <xsl:apply-templates select="//iso:rule[@id=current()/@rule]"
  832. mode="extends"/>
  833. </xsl:if>
  834. </xsl:template>
  835. <!-- KEY: ISO has no KEY -->
  836. <!-- NOTE:
  837. Key has had a checkered history. Schematron 1.0 allowed it in certain places, but
  838. users came up with a different location, which has now been adopted.
  839. XT, the early XSLT processor, did not implement key and died when it was present.
  840. So there are some versions of the Schematron skeleton for XT that strip out all
  841. key elements.
  842. Xalan (e.g. Xalan4C 1.0 and a Xalan4J) also had a funny. A fix involved making
  843. a top-level parameter called $hiddenKey and then using that instead of matching
  844. "key". This has been removed.
  845. -->
  846. <xsl:template match="xsl:key" mode="do-keys" >
  847. <xsl:if test="not(@name)">
  848. <xsl:message>Markup Error: no name attribute in &lt;key></xsl:message>
  849. </xsl:if>
  850. <xsl:if test="not(@path) and not(@use)">
  851. <xsl:message>Markup Error: no path or use attribute in &lt;key></xsl:message>
  852. </xsl:if>
  853. <xsl:choose>
  854. <xsl:when test="parent::iso:rule ">
  855. <xsl:call-template name="IamEmpty" />
  856. <xsl:choose>
  857. <xsl:when test="@path">
  858. <axsl:key match="{../@context}" name="{@name}" use="{@path}"/>
  859. </xsl:when>
  860. <xsl:otherwise>
  861. <axsl:key match="{../@context}" name="{@name}" use="{@use}"/>
  862. </xsl:otherwise>
  863. </xsl:choose>
  864. </xsl:when>
  865. <xsl:otherwise>
  866. <xsl:if test="not(@match) ">
  867. <xsl:message>Markup Error: no path or use attribute in &lt;key></xsl:message>
  868. </xsl:if>
  869. <axsl:key>
  870. <xsl:copy-of select="@*"/>
  871. </axsl:key>
  872. </xsl:otherwise>
  873. </xsl:choose>
  874. </xsl:template>
  875. <xsl:template match="xsl:key " /><!-- swallow -->
  876. <xsl:template match="iso:key " >
  877. <xsl:message>Schema error: The key element is not in the ISO Schematron namespace. Use the XSLT namespace.</xsl:message>
  878. </xsl:template>
  879. <!-- ISO INCLUDE -->
  880. <!-- This is only a fallback. Include really needs to have been done before this as a separate pass.-->
  881. <xsl:template match="iso:include[not(normalize-space(@href))]"
  882. priority="1">
  883. <xsl:if test=" $debug = 'false' ">
  884. <xsl:message terminate="yes">Schema error: Empty href= attribute for include directive.</xsl:message>
  885. </xsl:if>
  886. </xsl:template>
  887. <!-- Extend the URI syntax to allow # refererences -->
  888. <!-- Add experimental support for simple containers like /xxx:xxx/iso:pattern to allow better includes -->
  889. <xsl:template match="iso:include">
  890. <xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
  891. <xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
  892. <xsl:choose>
  893. <xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
  894. <xsl:message>Error: Impossible URL in Schematron include</xsl:message>
  895. </xsl:when>
  896. <xsl:when test="string-length( $fragment-id ) &gt; 0">
  897. <xsl:variable name="theDocument_1" select="document( $document-uri,/ )" />
  898. <xsl:variable name="theFragment_1" select="$theDocument_1//iso:*[@id= $fragment-id ]" />
  899. <xsl:if test=" $theFragment_1/self::iso:schema ">
  900. <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
  901. </xsl:if>
  902. <xsl:apply-templates select=" $theFragment_1"/>
  903. </xsl:when>
  904. <xsl:otherwise>
  905. <xsl:variable name="theDocument_2" select="document( $document-uri,/ )" />
  906. <xsl:variable name="theFragment_2" select="$theDocument_2/iso:*" />
  907. <xsl:variable name="theContainedFragments" select="$theDocument_2/*/iso:*" />
  908. <xsl:if test=" $theFragment_2/self::iso:schema or $theContainedFragments/self::iso:schema">
  909. <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
  910. </xsl:if>
  911. <xsl:apply-templates select="$theFragment_2 | $theContainedFragments "/>
  912. </xsl:otherwise>
  913. </xsl:choose>
  914. </xsl:template>
  915. <!-- This is to handle the particular case of including patterns -->
  916. <xsl:template match="iso:include" mode="do-all-patterns">
  917. <xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
  918. <xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
  919. <xsl:choose>
  920. <xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
  921. <xsl:message>Error: Impossible URL in Schematron include</xsl:message>
  922. </xsl:when>
  923. <xsl:when test="string-length( $fragment-id ) &gt; 0">
  924. <xsl:variable name="theDocument_1" select="document( $document-uri,/ )" />
  925. <xsl:variable name="theFragment_1" select="$theDocument_1//iso:*[@id= $fragment-id ]" />
  926. <xsl:if test=" $theFragment_1/self::iso:schema ">
  927. <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
  928. </xsl:if>
  929. <xsl:apply-templates select=" $theFragment_1" mode="do-all-patterns"/>
  930. </xsl:when>
  931. <xsl:otherwise>
  932. <!-- Import the top-level element if it is in schematron namespace,
  933. or its children otherwise, to allow a simple containment mechanism. -->
  934. <xsl:variable name="theDocument_2" select="document( $document-uri,/ )" />
  935. <xsl:variable name="theFragment_2" select="$theDocument_2/iso:*" />
  936. <xsl:variable name="theContainedFragments" select="$theDocument_2/*/iso:*" />
  937. <xsl:if test=" $theFragment_2/self::iso:schema or $theContainedFragments/self::iso:schema">
  938. <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
  939. </xsl:if>
  940. <xsl:apply-templates select="$theFragment_2 | $theContainedFragments "
  941. mode="do-all-patterns" />
  942. </xsl:otherwise>
  943. </xsl:choose>
  944. </xsl:template>
  945. <!-- ISO LET -->
  946. <xsl:template match="iso:let" >
  947. <xsl:if test="ancestor::iso:schema[@queryBinding='xpath']">
  948. <xsl:message>Warning: Variables should not be used with the "xpath" query language binding.</xsl:message>
  949. </xsl:if>
  950. <!-- lets at the top-level are implemented as parameters -->
  951. <xsl:choose>
  952. <xsl:when test="parent::iso:schema">
  953. <!-- it is an error to have an empty param/@select because an XPath is expected -->
  954. <axsl:param name="{@name}" select="{@value}">
  955. <xsl:if test="string-length(@value) &gt; 0">
  956. <xsl:attribute name="select"><xsl:value-of select="@value"/></xsl:attribute>
  957. </xsl:if>
  958. </axsl:param>
  959. </xsl:when>
  960. <xsl:otherwise>
  961. <axsl:variable name="{@name}" select="{@value}"/>
  962. </xsl:otherwise>
  963. </xsl:choose>
  964. </xsl:template>
  965. <!-- ISO NAME -->
  966. <xsl:template match="iso:name" mode="text">
  967. <xsl:if test="@path">
  968. <xsl:call-template name="process-name">
  969. <xsl:with-param name="name" select="concat('name(',@path,')')"/>
  970. </xsl:call-template>
  971. </xsl:if>
  972. <xsl:if test="not(@path)">
  973. <xsl:call-template name="process-name">
  974. <xsl:with-param name="name" select="'name(.)'"/>
  975. </xsl:call-template>
  976. </xsl:if>
  977. <xsl:call-template name="IamEmpty" />
  978. </xsl:template>
  979. <!-- ISO NS -->
  980. <!-- Namespace handling is XSLT is quite tricky and implementation dependent -->
  981. <xsl:template match="iso:ns">
  982. <xsl:call-template name="handle-namespace" />
  983. </xsl:template>
  984. <!-- This template is just to provide the API hook -->
  985. <xsl:template match="iso:ns" mode="do-all-patterns" >
  986. <xsl:if test="not(@uri)">
  987. <xsl:message>Markup Error: no uri attribute in &lt;ns></xsl:message>
  988. </xsl:if>
  989. <xsl:if test="not(@prefix)">
  990. <xsl:message>Markup Error: no prefix attribute in &lt;ns></xsl:message>
  991. </xsl:if>
  992. <xsl:call-template name="IamEmpty" />
  993. <xsl:call-template name="process-ns" >
  994. <xsl:with-param name="prefix" select="@prefix"/>
  995. <xsl:with-param name="uri" select="@uri"/>
  996. </xsl:call-template>
  997. </xsl:template>
  998. <!-- ISO P -->
  999. <xsl:template match="iso:schema/iso:p " mode="do-schema-p" >
  1000. <xsl:call-template name="process-p">
  1001. <xsl:with-param name="class" select="@class"/>
  1002. <xsl:with-param name="icon" select="@icon"/>
  1003. <xsl:with-param name="id" select="@id"/>
  1004. <xsl:with-param name="lang" select="@xml:lang"/>
  1005. </xsl:call-template>
  1006. </xsl:template>
  1007. <xsl:template match="iso:pattern/iso:p " mode="do-pattern-p" >
  1008. <xsl:call-template name="process-p">
  1009. <xsl:with-param name="class" select="@class"/>
  1010. <xsl:with-param name="icon" select="@icon"/>
  1011. <xsl:with-param name="id" select="@id"/>
  1012. <xsl:with-param name="lang" select="@xml:lang"/>
  1013. </xsl:call-template>
  1014. </xsl:template>
  1015. <!-- Currently, iso:p in other position are not passed through to the API -->
  1016. <xsl:template match="iso:phase/iso:p" />
  1017. <xsl:template match="iso:p " priority="-1" />
  1018. <!-- ISO PATTERN -->
  1019. <xsl:template match="iso:pattern" mode="do-all-patterns">
  1020. <xsl:if test="($phase = '#ALL')
  1021. or (../iso:phase[@id= $phase]/iso:active[@pattern= current()/@id])">
  1022. <xsl:call-template name="process-pattern">
  1023. <!-- the following select statement assumes that
  1024. @id | sch:title returns node-set in document order:
  1025. we want the title if it is there, otherwise the @id attribute -->
  1026. <xsl:with-param name="name" select="(@id | iso:title )[last()]"/>
  1027. <xsl:with-param name="is-a" select="''"/>
  1028. <!-- "Rich" properties -->
  1029. <xsl:with-param name="fpi" select="@fpi"/>
  1030. <xsl:with-param name="icon" select="@icon"/>
  1031. <xsl:with-param name="id" select="@id"/>
  1032. <xsl:with-param name="lang" select="@xml:lang"/>
  1033. <xsl:with-param name="see" select="@see" />
  1034. <xsl:with-param name="space" select="@xml:space" />
  1035. </xsl:call-template>
  1036. <xsl:choose>
  1037. <xsl:when test="$select-contexts='key'">
  1038. <axsl:apply-templates select="key('M','M{count(preceding-sibling::*)}')" mode="M{count(preceding-sibling::*)}"/>
  1039. </xsl:when>
  1040. <xsl:when test="$select-contexts='//'">
  1041. <axsl:apply-templates mode="M{count(preceding-sibling::*)}">
  1042. <xsl:attribute name="select">
  1043. <xsl:text>//(</xsl:text>
  1044. <xsl:for-each select="iso:rule/@context">
  1045. <xsl:text>(</xsl:text>
  1046. <xsl:value-of select="."/>
  1047. <xsl:text>)</xsl:text>
  1048. <xsl:if test="position()!=last()">|</xsl:if>
  1049. </xsl:for-each>
  1050. <xsl:text>)</xsl:text>
  1051. <xsl:if test="$visit-text='false'">[not(self::text())]</xsl:if>
  1052. </xsl:attribute>
  1053. </axsl:apply-templates>
  1054. </xsl:when>
  1055. <xsl:otherwise>
  1056. <axsl:apply-templates select="/" mode="M{count(preceding-sibling::*)}"/>
  1057. </xsl:otherwise>
  1058. </xsl:choose>
  1059. </xsl:if>
  1060. </xsl:template>
  1061. <xsl:template match="iso:pattern[@abstract='true']">
  1062. <xsl:message>Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already
  1063. </xsl:message>
  1064. </xsl:template>
  1065. <!-- Here is the template for the normal case of patterns -->
  1066. <xsl:template match="iso:pattern[not(@abstract='true')]">
  1067. <xsl:if test="($phase = '#ALL')
  1068. or (../iso:phase[@id= $phase]/iso:active[@pattern= current()/@id])">
  1069. <xsl:text>&#10;&#10;</xsl:text>
  1070. <xsl:comment>PATTERN <xsl:value-of select="@id" /> <xsl:value-of select="iso:title" /> </xsl:comment><xsl:text>&#10;</xsl:text>
  1071. <xsl:apply-templates />
  1072. <!-- DPC select-contexts test -->
  1073. <xsl:if test="not($select-contexts)">
  1074. <axsl:template match="text()" priority="-1" mode="M{count(preceding-sibling::*)}">
  1075. <!-- strip characters -->
  1076. </axsl:template>
  1077. <!-- DPC introduce context-xpath variable -->
  1078. <axsl:template match="@*|node()"
  1079. priority="-2"
  1080. mode="M{ count(preceding-sibling::*) }">
  1081. <axsl:apply-templates select="{$context-xpath}" mode="M{count(preceding-sibling::*)}"/>
  1082. </axsl:template>
  1083. </xsl:if>
  1084. </xsl:if>
  1085. </xsl:template>
  1086. <!-- ISO PHASE -->
  1087. <xsl:template match="iso:phase" >
  1088. <xsl:if test="not(@id)">
  1089. <xsl:message>Markup Error: no id attribute in &lt;phase></xsl:message>
  1090. </xsl:if>
  1091. <xsl:apply-templates/>
  1092. </xsl:template>
  1093. <!-- ISO RULE -->
  1094. <xsl:template match="iso:rule[not(@abstract='true')] ">
  1095. <xsl:if test="not(@context)">
  1096. <xsl:message>Markup Error: no context attribute in &lt;rule></xsl:message>
  1097. </xsl:if>
  1098. <xsl:text>&#10;&#10; </xsl:text>
  1099. <xsl:comment>RULE <xsl:value-of select="@id" /> </xsl:comment><xsl:text>&#10;</xsl:text>
  1100. <xsl:if test="iso:title">
  1101. <xsl:comment><xsl:value-of select="iso:title" /></xsl:comment>
  1102. </xsl:if>
  1103. <!-- DPC select-contexts -->
  1104. <xsl:if test="$select-contexts='key'">
  1105. <axsl:key name="M"
  1106. match="{@context}"
  1107. use="'M{count(../preceding-sibling::*)}'"/>
  1108. </xsl:if>
  1109. <!-- DPC priorities count up from 1000 not down from 4000 (templates in same priority order as before) -->
  1110. <axsl:template match="{@context}"
  1111. priority="{1000 + count(following-sibling::*)}" mode="M{count(../preceding-sibling::*)}">
  1112. <xsl:call-template name="process-rule">
  1113. <xsl:with-param name="context" select="@context"/>
  1114. <!-- "Rich" properties -->
  1115. <xsl:with-param name="fpi" select="@fpi"/>
  1116. <xsl:with-param name="icon" select="@icon"/>
  1117. <xsl:with-param name="id" select="@id"/>
  1118. <xsl:with-param name="lang" select="@xml:lang"/>
  1119. <xsl:with-param name="see" select="@see" />
  1120. <xsl:with-param name="space" select="@xml:space" />
  1121. <!-- "Linking" properties -->
  1122. <xsl:with-param name="role" select="@role" />
  1123. <xsl:with-param name="subject" select="@subject" />
  1124. </xsl:call-template>
  1125. <xsl:apply-templates/>
  1126. <!-- DPC introduce context-xpath and select-contexts variables -->
  1127. <xsl:if test="not($select-contexts)">
  1128. <axsl:apply-templates select="{$context-xpath}" mode="M{count(../preceding-sibling::*)}"/>
  1129. </xsl:if>
  1130. </axsl:template>
  1131. </xsl:template>
  1132. <!-- ISO ABSTRACT RULE -->
  1133. <xsl:template match="iso:rule[@abstract='true'] " >
  1134. <xsl:if test=" not(@id)">
  1135. <xsl:message>Markup Error: no id attribute on abstract &lt;rule></xsl:message>
  1136. </xsl:if>
  1137. <xsl:if test="@context">
  1138. <xsl:message>Markup Error: (2) context attribute on abstract &lt;rule></xsl:message>
  1139. </xsl:if>
  1140. </xsl:template>
  1141. <xsl:template match="iso:rule[@abstract='true']"
  1142. mode="extends" >
  1143. <xsl:if test="@context">
  1144. <xsl:message>Markup Error: context attribute on abstract &lt;rule></xsl:message>
  1145. </xsl:if>
  1146. <xsl:apply-templates/>
  1147. </xsl:template>
  1148. <!-- ISO SPAN -->
  1149. <xsl:template match="iso:span" mode="text">
  1150. <xsl:call-template name="process-span">
  1151. <xsl:with-param name="class" select="@class"/>
  1152. </xsl:call-template>
  1153. </xsl:template>
  1154. <!-- ISO TITLE -->
  1155. <xsl:template match="iso:schema/iso:title" priority="1">
  1156. <xsl:call-template name="process-schema-title" />
  1157. </xsl:template>
  1158. <xsl:template match="iso:title" >
  1159. <xsl:call-template name="process-title" />
  1160. </xsl:template>
  1161. <!-- ISO VALUE-OF -->
  1162. <xsl:template match="iso:value-of" mode="text" >
  1163. <xsl:if test="not(@select)">
  1164. <xsl:message>Markup Error: no select attribute in &lt;value-of></xsl:message>
  1165. </xsl:if>
  1166. <xsl:call-template name="IamEmpty" />
  1167. <xsl:choose>
  1168. <xsl:when test="@select">
  1169. <xsl:call-template name="process-value-of">
  1170. <xsl:with-param name="select" select="@select"/>
  1171. </xsl:call-template>
  1172. </xsl:when>
  1173. <xsl:otherwise >
  1174. <xsl:call-template name="process-value-of">
  1175. <xsl:with-param name="select" select="'.'"/>
  1176. </xsl:call-template>
  1177. </xsl:otherwise>
  1178. </xsl:choose>
  1179. </xsl:template>
  1180. <!-- ============================================================== -->
  1181. <!-- DEFAULT TEXT HANDLING -->
  1182. <!-- ============================================================== -->
  1183. <xsl:template match="text()" priority="-1" mode="do-keys">
  1184. <!-- strip characters -->
  1185. </xsl:template>
  1186. <xsl:template match="text()" priority="-1" mode="do-all-patterns">
  1187. <!-- strip characters -->
  1188. </xsl:template>
  1189. <xsl:template match="text()" priority="-1" mode="do-schema-p">
  1190. <!-- strip characters -->
  1191. </xsl:template>
  1192. <xsl:template match="text()" priority="-1" mode="do-pattern-p">
  1193. <!-- strip characters -->
  1194. </xsl:template>
  1195. <xsl:template match="text()" priority="-1">
  1196. <!-- Strip characters -->
  1197. </xsl:template>
  1198. <xsl:template match="text()" mode="text">
  1199. <xsl:value-of select="."/>
  1200. </xsl:template>
  1201. <xsl:template match="text()" mode="inline-text">
  1202. <xsl:value-of select="."/>
  1203. </xsl:template>
  1204. <!-- ============================================================== -->
  1205. <!-- UTILITY TEMPLATES -->
  1206. <!-- ============================================================== -->
  1207. <xsl:template name="IamEmpty">
  1208. <xsl:if test="count( * )">
  1209. <xsl:message>
  1210. <xsl:text>Warning: </xsl:text>
  1211. <xsl:value-of select="name(.)"/>
  1212. <xsl:text> must not contain any child elements</xsl:text>
  1213. </xsl:message>
  1214. </xsl:if>
  1215. </xsl:template>
  1216. <xsl:template name="diagnosticsSplit">
  1217. <!-- Process at the current point the first of the <diagnostic> elements
  1218. referred to parameter str, and then recurse -->
  1219. <xsl:param name="str"/>
  1220. <xsl:variable name="start">
  1221. <xsl:choose>
  1222. <xsl:when test="contains($str,' ')">
  1223. <xsl:value-of select="substring-before($str,' ')"/>
  1224. </xsl:when>
  1225. <xsl:otherwise><xsl:value-of select="$str"/></xsl:otherwise>
  1226. </xsl:choose>
  1227. </xsl:variable>
  1228. <xsl:variable name="end">
  1229. <xsl:if test="contains($str,' ')">
  1230. <xsl:value-of select="substring-after($str,' ')"/>
  1231. </xsl:if>
  1232. </xsl:variable>
  1233. <!-- This works with all namespaces -->
  1234. <xsl:if test="not(string-length(normalize-space($start)) = 0)
  1235. and not(//iso:diagnostic[@id = $start])
  1236. and not(//sch:diagnostic[@id = $start])
  1237. and not(//diagnostic[@id = $start])">
  1238. <xsl:message>Reference error: A diagnostic "<xsl:value-of select="string($start)"
  1239. />" has been referenced but is not declared</xsl:message>
  1240. </xsl:if>
  1241. <xsl:if test="string-length(normalize-space($start)) > 0">
  1242. <xsl:text> </xsl:text>
  1243. <xsl:apply-templates
  1244. select="//iso:diagnostic[@id = $start ]
  1245. | //sch:diagnostic[@id = $start ]
  1246. | //diagnostic[@id= $start ]"/>
  1247. </xsl:if>
  1248. <xsl:if test="not($end='')">
  1249. <xsl:call-template name="diagnosticsSplit">
  1250. <xsl:with-param name="str" select="$end"/>
  1251. </xsl:call-template>
  1252. </xsl:if>
  1253. </xsl:template>
  1254. <!-- It would be nice to use this but xsl:namespace does not
  1255. allow a fallback -->
  1256. <!--xsl:template name="handle-namespace" version="2.0">
  1257. <xsl:namespace name="{@prefix}" select="@uri">
  1258. </xsl:template-->
  1259. <xsl:template name="handle-namespace">
  1260. <!-- experimental code from http://eccnet.eccnet.com/pipermail/schematron-love-in/2006-June/000104.html -->
  1261. <!-- Handle namespaces differently for exslt systems, msxml, and default, only using XSLT1 syntax -->
  1262. <!-- For more info see http://fgeorges.blogspot.com/2007/01/creating-namespace-nodes-in-xslt-10.html -->
  1263. <xsl:choose>
  1264. <!-- The following code works for XSLT1 -->
  1265. <xsl:when test="function-available('exsl:node-set')">
  1266. <xsl:variable name="ns-dummy-elements">
  1267. <xsl:element name="{@prefix}:dummy" namespace="{@uri}"/>
  1268. </xsl:variable>
  1269. <xsl:variable name="p" select="@prefix"/>
  1270. <xsl:copy-of select="exsl:node-set($ns-dummy-elements)
  1271. /*/namespace::*[local-name()=$p]"/>
  1272. </xsl:when>
  1273. <!-- End XSLT1 code -->
  1274. <!-- Not tested yet
  1275. <xsl:when test="function-available('msxsl:node-set')">
  1276. <xsl:variable name="ns-dummy-elements">
  1277. <xsl:element name="{ $prefix }:e" namespace="{ $uri }"/>
  1278. </xsl:variable>
  1279. <xsl:copy-of select="msxsl:node-set($ns-dummy-elements)/*/namespace::*"/>
  1280. </xsl:when>
  1281. -->
  1282. <xsl:when test="@prefix = 'xsl' ">
  1283. <!-- Do not generate dummy attributes with the xsl: prefix, as these
  1284. are errors against XSLT, because we presume that the output
  1285. stylesheet uses the xsl prefix. In any case, there would already
  1286. be a namespace declaration for the XSLT namespace generated
  1287. automatically, presumably using "xsl:".
  1288. -->
  1289. </xsl:when>
  1290. <xsl:when test="@uri = 'http://www.w3.org/1999/XSL/Transform'">
  1291. <xsl:message terminate="yes">
  1292. <xsl:text>Using the XSLT namespace with a prefix other than "xsl" in </xsl:text>
  1293. <xsl:text>Schematron rules is not supported </xsl:text>
  1294. <xsl:text>in this processor: </xsl:text>
  1295. <xsl:value-of select="system-property('xsl:vendor')"/>
  1296. </xsl:message>
  1297. </xsl:when>
  1298. <xsl:otherwise>
  1299. <xsl:attribute name="{concat(@prefix,':dummy-for-xmlns')}" namespace="{@uri}" />
  1300. </xsl:otherwise>
  1301. </xsl:choose>
  1302. </xsl:template>
  1303. <!-- ============================================================== -->
  1304. <!-- UNEXPECTED ELEMENTS -->
  1305. <!-- ============================================================== -->
  1306. <xsl:template match="iso:*" priority="-2">
  1307. <xsl:message>
  1308. <xsl:text>Error: unrecognized element in ISO Schematron namespace: check spelling
  1309. and capitalization</xsl:text>
  1310. <xsl:value-of select="name(.)"/>
  1311. </xsl:message>
  1312. </xsl:template>
  1313. <!-- Swallow old namespace elements: there is an upfront test for them elsewhere -->
  1314. <xsl:template match="sch:*" priority="-2" />
  1315. <xsl:template match="*" priority="-3">
  1316. <xsl:choose>
  1317. <xsl:when test=" $allow-foreign = 'false' ">
  1318. <xsl:message>
  1319. <xsl:text>Warning: unrecognized element </xsl:text>
  1320. <xsl:value-of select="name(.)"/>
  1321. </xsl:message>
  1322. </xsl:when>
  1323. <xsl:otherwise>
  1324. <xsl:copy-of select="." />
  1325. </xsl:otherwise>
  1326. </xsl:choose>
  1327. </xsl:template>
  1328. <xsl:template match="iso:*" mode="text" priority="-2" />
  1329. <xsl:template match="*" mode="text" priority="-3">
  1330. <xsl:choose>
  1331. <xsl:when test=" $allow-foreign = 'false' ">
  1332. <xsl:message>
  1333. <xsl:text>Warning: unrecognized element </xsl:text>
  1334. <xsl:value-of select="name(.)"/>
  1335. </xsl:message>
  1336. </xsl:when>
  1337. <xsl:otherwise>
  1338. <xsl:copy-of select="." />
  1339. </xsl:otherwise>
  1340. </xsl:choose>
  1341. </xsl:template>
  1342. <!-- ============================================================== -->
  1343. <!-- DEFAULT NAMED TEMPLATES -->
  1344. <!-- These are the actions that are performed unless overridden -->
  1345. <!-- ============================================================== -->
  1346. <xsl:template name="process-prolog"/>
  1347. <!-- no params -->
  1348. <xsl:template name="process-root">
  1349. <xsl:param name="contents"/>
  1350. <xsl:param name="id" />
  1351. <xsl:param name="version" />
  1352. <xsl:param name="schemaVersion" />
  1353. <xsl:param name="queryBinding" />
  1354. <xsl:param name="title" />
  1355. <!-- "Rich" parameters -->
  1356. <xsl:param name="fpi" />
  1357. <xsl:param name="icon" />
  1358. <xsl:param name="lang" />
  1359. <xsl:param name="see" />
  1360. <xsl:param name="space" />
  1361. <xsl:copy-of select="$contents"/>
  1362. </xsl:template>
  1363. <xsl:template name="process-assert">
  1364. <xsl:param name="test"/>
  1365. <xsl:param name="diagnostics" />
  1366. <xsl:param name="id" />
  1367. <xsl:param name="flag" />
  1368. <!-- "Linkable" parameters -->
  1369. <xsl:param name="role"/>
  1370. <xsl:param name="subject"/>
  1371. <!-- "Rich" parameters -->
  1372. <xsl:param name="fpi" />
  1373. <xsl:param name="icon" />
  1374. <xsl:param name="lang" />
  1375. <xsl:param name="see" />
  1376. <xsl:param name="space" />
  1377. <xsl:call-template name="process-message">
  1378. <xsl:with-param name="pattern" select="$test"/>
  1379. <xsl:with-param name="role" select="$role"/>
  1380. </xsl:call-template>
  1381. </xsl:template>
  1382. <xsl:template name="process-report">
  1383. <xsl:param name="test"/>
  1384. <xsl:param name="diagnostics" />
  1385. <xsl:param name="id" />
  1386. <xsl:param name="flag" />
  1387. <!-- "Linkable" parameters -->
  1388. <xsl:param name="role"/>
  1389. <xsl:param name="subject"/>
  1390. <!-- "Rich" parameters -->
  1391. <xsl:param name="fpi" />
  1392. <xsl:param name="icon" />
  1393. <xsl:param name="lang" />
  1394. <xsl:param name="see" />
  1395. <xsl:param name="space" />
  1396. <xsl:call-template name="process-message">
  1397. <xsl:with-param name="pattern" select="$test"/>
  1398. <xsl:with-param name="role" select="$role"/>
  1399. </xsl:call-template>
  1400. </xsl:template>
  1401. <xsl:template name="process-diagnostic">
  1402. <xsl:param name="id" />
  1403. <!-- "Rich" parameters -->
  1404. <xsl:param name="fpi" />
  1405. <xsl:param name="icon" />
  1406. <xsl:param name="lang" />
  1407. <xsl:param name="see" />
  1408. <xsl:param name="space" />
  1409. <!-- We generate too much whitespace rather than risking concatenation -->
  1410. <axsl:text> </axsl:text>
  1411. <xsl:apply-templates mode="text"/>
  1412. <axsl:text> </axsl:text>
  1413. </xsl:template>
  1414. <xsl:template name="process-dir">
  1415. <xsl:param name="value" />
  1416. <!-- We generate too much whitespace rather than risking concatenation -->
  1417. <axsl:text> </axsl:text>
  1418. <xsl:apply-templates mode="inline-text"/>
  1419. <axsl:text> </axsl:text>
  1420. </xsl:template>
  1421. <xsl:template name="process-emph">
  1422. <!-- We generate too much whitespace rather than risking concatenation -->
  1423. <axsl:text> </axsl:text>
  1424. <xsl:apply-templates mode="inline-text"/>
  1425. <axsl:text> </axsl:text>
  1426. </xsl:template>
  1427. <xsl:template name="process-name">
  1428. <xsl:param name="name"/>
  1429. <!-- We generate too much whitespace rather than risking concatenation -->
  1430. <axsl:text> </axsl:text>
  1431. <axsl:value-of select="{$name}"/>
  1432. <axsl:text> </axsl:text>
  1433. </xsl:template>
  1434. <xsl:template name="process-ns" >
  1435. <!-- Note that process-ns is for reporting. The sch:ns elements are
  1436. independently used in the sch:schema template to provide namespace bindings -->
  1437. <xsl:param name="prefix"/>
  1438. <xsl:param name="uri" />
  1439. </xsl:template>
  1440. <xsl:template name="process-p">
  1441. <xsl:param name="id" />
  1442. <xsl:param name="class" />
  1443. <xsl:param name="icon" />
  1444. <xsl:param name="lang" />
  1445. </xsl:template>
  1446. <xsl:template name="process-pattern">
  1447. <xsl:param name="id" />
  1448. <xsl:param name="name" />
  1449. <xsl:param name="is-a" />
  1450. <!-- "Rich" parameters -->
  1451. <xsl:param name="fpi" />
  1452. <xsl:param name="icon" />
  1453. <xsl:param name="lang" />
  1454. <xsl:param name="see" />
  1455. <xsl:param name="space" />
  1456. </xsl:template>
  1457. <xsl:template name="process-rule">
  1458. <xsl:param name="context" />
  1459. <xsl:param name="id" />
  1460. <xsl:param name="flag" />
  1461. <!-- "Linkable" parameters -->
  1462. <xsl:param name="role"/>
  1463. <xsl:param name="subject"/>
  1464. <!-- "Rich" parameters -->
  1465. <xsl:param name="fpi" />
  1466. <xsl:param name="icon" />
  1467. <xsl:param name="lang" />
  1468. <xsl:param name="see" />
  1469. <xsl:param name="space" />
  1470. </xsl:template>
  1471. <xsl:template name="process-span" >
  1472. <xsl:param name="class" />
  1473. <!-- We generate too much whitespace rather than risking concatenation -->
  1474. <axsl:text> </axsl:text>
  1475. <xsl:apply-templates mode="inline-text"/>
  1476. <axsl:text> </axsl:text>
  1477. </xsl:template>
  1478. <xsl:template name="process-title" >
  1479. <xsl:param name="class" />
  1480. <xsl:call-template name="process-p">
  1481. <xsl:with-param name="class">title</xsl:with-param>
  1482. </xsl:call-template>
  1483. </xsl:template>
  1484. <xsl:template name="process-schema-title" >
  1485. <xsl:param name="class" />
  1486. <xsl:call-template name="process-title">
  1487. <xsl:with-param name="class">schema-title</xsl:with-param>
  1488. </xsl:call-template>
  1489. </xsl:template>
  1490. <xsl:template name="process-value-of">
  1491. <xsl:param name="select"/>
  1492. <!-- We generate too much whitespace rather than risking concatenation -->
  1493. <axsl:text> </axsl:text>
  1494. <axsl:value-of select="{$select}"/>
  1495. <axsl:text> </axsl:text>
  1496. </xsl:template>
  1497. <!-- default output action: the simplest customization is to just override this -->
  1498. <xsl:template name="process-message">
  1499. <xsl:param name="pattern" />
  1500. <xsl:param name="role" />
  1501. <xsl:apply-templates mode="text"/>
  1502. <xsl:if test=" $message-newline = 'true'" >
  1503. <axsl:value-of select="string('&#10;')"/>
  1504. </xsl:if>
  1505. </xsl:template>
  1506. </xsl:stylesheet>