add files

This commit is contained in:
ChiKyun Kim
2025-09-09 13:59:12 +09:00
parent e94b06888d
commit 747aabe224
791 changed files with 3888723 additions and 0 deletions

View File

@@ -0,0 +1,484 @@
<?xml version="1.0" encoding="UTF-8"?><?xar XSLT?>
<!--
==============================================================
DOCUMENTATION
==============================================================
Input: valid ISO 19575-3 document: a Schematron schema
Output: valid TR 9537-11 fragment: an annex for an ISO Standard
This stylesheet converts a Schematron schema into an annex for
an ISO standard or technical report, using the TR 9537-11 schema.
* Titles become annex or clause titles
* Each pattern is a clause
* Within each pattern, all the assertions are presented in a numbered
list as constraints.
* Within each pattern, all the reports are gathered into a separate
numbered lists, as thing that an implementations should report
* Abstract rules may be used. These are repeated each time, with the <name>
element acting correctly (for elements at least)
* A paragraph of documentation uses the plain <p> element. Other kinds of
blocks elements from TR9537-11 can be represented using the class attribute
on the <p> element. Warnings, list items, examples, and pre elements,
in particular; consecutive list items will be wrapped in the appropriate
container; multi-paragraph warnings, list items, etc are not supported.
* Tables, images and definition lists are not supported.
* The Schematron phase mechanism can be used to generate conformance classes
or levels, by selecting patterns.
* The inline elements can be used with the <span> element by providing their
name in the class attribute, except for tables and artwork.
* The following Schematron features are not transformed: diagnostics, namespace
and query language.
* The following Schematron features are probably not useful: abstract patterns,
abstract rules
* The @see attribute can be used for bibliographic references (to URLs) but it
will require hand correction to link to the proper bibliographic items, which
are not generated by this converter.
-->
<!--
Open Source Initiative OSI - The MIT License:Licensing
[OSI Approved License]
The MIT License
Copyright (c) 2008-2010 Rick Jelliffe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<xsl:stylesheet version="1.0"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://purl.oclc.org/dsdl/9573-11amd1/ns/structure/1.0" >
<!--
==============================================================
DECLARATIONS
==============================================================
-->
<xsl:output method="xml" omit-xml-declaration="no" standalone="yes" indent="yes" />
<!--
==============================================================
SCHEMA ELEMENT
==============================================================
-->
<xsl:template match="sch:schema">
<annex normative="true" id="schematron-derived-annex" xmlns="http://purl.oclc.org/dsdl/9573-11amd1/ns/structure/1.0">
<xsl:comment>May need xmlns="http://purl.oclc.org/dsdl/9573-11amd1/ns/structure/1.0"</xsl:comment>
<xsl:apply-templates select="sch:title" />
<clause id="schematron-derived-annex-intro">
<title>Introduction</title>
<xsl:apply-templates select="sch:p[not(preceding-sibling::sch:pattern)]" />
<xsl:if test="sch:ns">
<p>The following table lists the namespaces and typical prefixes.</p>
<p><tabular frame="all">
<tgroup cols="2">
<thead>
<row><entry>Prefix</entry><entry>Namespace IRI</entry></row>
</thead>
<tbody>
<xsl:apply-templates select="sch:ns" />
</tbody>
</tgroup>
</tabular>
</p>
</xsl:if>
<xsl:if test="not(sch:ns)">
<p>The constraints in this document apply to elements which are not in any namespace.</p>
</xsl:if>
</clause>
<xsl:if test="sch:phase">
<clause id="schematron-derived-annex-conform">
<title>Conformance Profiles</title>
<p>The following clauses define named conformance profiles. Each profile specifies a subset of
the constraints and reporting requirements.</p>
<xsl:apply-templates select="sch:phase" />
</clause>
</xsl:if>
<xsl:apply-templates select="sch:phase" />
<xsl:apply-templates select="sch:pattern" />
<xsl:apply-templates select="sch:p[preceding-sibling::sch:pattern]" />
</annex>
</xsl:template>
<!-- INCLUDE -->
<xsl:template match="sch:include[not(normalize-space(@href))]" priority="1">
<xsl:message terminate="yes">Schema error: Empty href= attribute for include directive.</xsl:message>
</xsl:template>
<!-- Extend the URI syntax to allow # refererences -->
<xsl:template match="sch:include">
<xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
<xsl:choose>
<xsl:when test="$fragment-id">
<xsl:apply-templates select="document( $document-uri,/ )//sch:*[@id= $fragment-id ]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="document( $document-uri,/ )/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
==============================================================
OTHER SCHEMA ELEMENTS
==============================================================
-->
<!-- ACTIVE -->
<xsl:template match="sch:active">
<li><p><xref to="{@pattern}" />
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p>
</li>
</xsl:template>
<!-- ASSERT and REPORT-->
<xsl:template match="sch:assert" mode="handle-asserts">
<xsl:param name="context">UNAVAILABLE</xsl:param>
<li><p><xsl:apply-templates >
<xsl:with-param name="a-context" select="$context" />
</xsl:apply-templates>
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p></li>
</xsl:template>
<xsl:template match="sch:report" mode="handle-reports">
<xsl:param name="context">UNAVAILABLE</xsl:param>
<li><p><xsl:apply-templates >
<xsl:with-param name="a-context" select="$context" />
</xsl:apply-templates>
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p></li>
</xsl:template>
<xsl:template match="sch:assert | sch:report " />
<!-- DIAGNOSTIC -->
<xsl:template match="sch:diagnostic">
</xsl:template>
<!-- DIAGNOSTICS -->
<!-- no diagnostics -->
<xsl:template match="sch:diagnostics">
</xsl:template>
<!-- DIR -->
<xsl:template match="sch:dir">
<xsl:apply-templates />
</xsl:template>
<!-- EMPH -->
<xsl:template match="sch:emph">
<strong><xsl:apply-templates /></strong>
</xsl:template>
<!-- EXTENDS -->
<xsl:template match="sch:extends" />
<!-- Handle asserts when a normal rule has an extension -->
<xsl:template match="sch:rule[not(@abstract='true')]/sch:extends" mode="handle-asserts">
<xsl:apply-templates select="//sch:rule[@abstract='true'][@id=current()/@rule]" mode="handle-asserts" >
<xsl:with-param name="context" select="../@context" />
</xsl:apply-templates>
</xsl:template>
<!-- Handle asserts when an abstract rule has an extension -->
<xsl:template match="sch:rule[@abstract='true']/sch:extends" mode="handle-asserts">
<xsl:param name="context">UNKNOWN</xsl:param>
<xsl:apply-templates select="//sch:rule[@abstract='true'][@id=current()/@rule]" mode="handle-asserts" >
<xsl:with-param name="context" select="$context" />
</xsl:apply-templates>
</xsl:template>
<!-- Handle reports when a normal rule has an extension -->
<xsl:template match="sch:rule[not(@abstract='true')]/sch:extends" mode="handle-reports">
<xsl:apply-templates select="//sch:rule[@abstract='true'][@id=current()/@rule]" mode="handle-reports" >
<xsl:with-param name="context" select="../@context" />
</xsl:apply-templates>
</xsl:template>
<!-- Handle reports when an abstract rule has an extension -->
<xsl:template match="sch:rule[@abstract='true']/sch:extends" mode="handle-reports">
<xsl:param name="context">UNKNOWN</xsl:param>
<xsl:variable name="context" select="../@context" />
<xsl:apply-templates select="//sch:rule[@abstract='true'][@id=current()/@rule]" mode="handle-reports" >
<xsl:with-param name="context" select="$context" />
</xsl:apply-templates>
</xsl:template>
<!-- XSL:KEY -->
<xsl:template match="xsl:key">
</xsl:template>
<!-- LET -->
<xsl:template match="sch:let">
</xsl:template>
<!-- NAME -->
<!-- Handle names in abstract rules -->
<xsl:template match="sch:name[ancestor::sch:rule[not(@abstract='true')]]" priority="3">
<!-- not quite right. need to handle subject and name having explicit path -->
<code><xsl:value-of select="../../@context"/></code>
</xsl:template>
<xsl:template match="sch:name[ancestor::sch:rule[not(@abstract='true')]][ancestor::sch:pattern[@abstract='true']]" priority="4">
<!-- not quite right. need to handle subject and name having explicit path -->
<code><i><xsl:value-of select="../../@context"/></i></code>
</xsl:template>
<xsl:template match="sch:name[ancestor::sch:pattern[@abstract='true']]" priority="2">
<xsl:param name="a-context">MISSING</xsl:param>
<!-- not quite right. need to handle subject and name having explicit path -->
<code><i><xsl:value-of select="$a-context"/></i></code>
</xsl:template>
<xsl:template match="sch:name">
<xsl:param name="a-context">MISSING</xsl:param>
<!-- not quite right. need to handle subject and name having explicit path -->
<code><xsl:value-of select="$a-context"/></code>
</xsl:template>
<!-- NS -->
<xsl:template match="sch:ns">
<row><entry><xsl:value-of select="@prefix" /></entry>
<entry><xsl:value-of select="@uri" /></entry></row>
</xsl:template>
<!-- P -->
<xsl:template match="sch:p[@class]" priority="1">
<!-- common case is that class = ol or ul need to become list items -->
<xsl:choose>
<xsl:when test="@class='ul'">
<xsl:if test="not(preceding-sibling::sch:p[@class='ul'])">
<xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
</xsl:if>
<li><p><xsl:apply-templates />
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p></li>
<xsl:if test="not(following-sibling::sch:p[@class='ul'])">
<xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
</xsl:if>
</xsl:when>
<xsl:when test="@class='ol'">
<xsl:if test="not(preceding-sibling::sch:p[@class='ol'])">
<xsl:text disable-output-escaping="yes">&lt;ol&gt;</xsl:text>
</xsl:if>
<li><p><xsl:apply-templates />
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p>
</li>
<xsl:if test="not(following-sibling::sch:p[@class='ol'])">
<xsl:text disable-output-escaping="yes">&lt;/ol&gt;</xsl:text>
</xsl:if>
</xsl:when>
<xsl:when test="@class='note'">
<!-- only single para notes -->
<note><p><xsl:apply-templates/>
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p></note>
</xsl:when>
<xsl:when test="@class='genwarn'or @class='warning' or @class='caution' or @class='remark'">
<!-- only single para warnings -->
<warn format="{@class}"><p><xsl:apply-templates/>
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p></warn>
</xsl:when>
<xsl:when test="@class='example'">
<!-- only single para example -->
<example><p><xsl:apply-templates/></p></example>
</xsl:when>
<xsl:when test="@class='pre'">
<!-- only single para example -->
<pre xml:space="preserve"><xsl:apply-templates/></pre>
</xsl:when>
<xsl:otherwise>
<p><xsl:comment><xsl:value-of select="@class"/></xsl:comment><xsl:apply-templates />
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="sch:p">
<p><xsl:apply-templates />
<xsl:if test="@see"><footnote>Refer <code><xsl:value-of select="@see"/></code>.
<xsl:comment>Hand edit required to replace this with proper xref to bibliography!</xsl:comment></footnote></xsl:if>
</p>
</xsl:template>
<!-- PATTERN -->
<xsl:template match="sch:pattern[@abstract='true']" priority="1" >
<clause id="{concat('schematron-derived-annex-', @id)}">
<xsl:apply-templates select="sch:title"/>
<xsl:apply-templates select="sch:p"/>
<p>For each of the following parameter tables, the constraints below apply.</p>
<note><p>The following names and values may be XPath expressions. <code>@</code> is
selects an attribute name. <code>$</code> selects a parameter. </p></note>
<ol>
<xsl:for-each select="//sch:pattern[@is-a=current()/@id]">
<li><p>
<tabular frame="all">
<tgroup cols="2">
<thead><row><entry>Parameter Name</entry><entry>Parameter Value</entry></row></thead>
<tbody>
<xsl:for-each select="sch:param">
<row><entry><code><i><xsl:value-of select="@name"/></i></code></entry>
<entry><xsl:value-of select="@value"/></entry>
</row>
</xsl:for-each>
</tbody>
</tgroup>
</tabular>
</p></li>
</xsl:for-each>
</ol>
<xsl:if test="sch:rule/sch:assert">
<p>To conform to this clause, a document should conform to the following constraints,
after substituting named parameters with the value above in each each case:</p>
<ol><xsl:apply-templates select="sch:rule[not(@abstract='true')]" mode="handle-asserts" /></ol>
</xsl:if>
<xsl:if test="sch:rule/sch:report">
<p>To conform to this clause, an application should report the following cases,
after substituting named parameters with the value above in each each case:</p>
<ol><xsl:apply-templates select="sch:rule[not(@abstract='true')]" mode="handle-reports" /></ol>
</xsl:if>
</clause>
</xsl:template>
<xsl:template match="sch:pattern[@is-a]" priority="1">
</xsl:template>
<xsl:template match="sch:pattern">
<clause id="{concat('schematron-derived-annex-', @id)}">
<xsl:apply-templates select="sch:title"/>
<xsl:apply-templates select="sch:p"/>
<xsl:if test="sch:rule/sch:assert">
<p>To conform to this clause, a document should conform to the following constraints:</p>
<ol><xsl:apply-templates select="sch:rule[not(@abstract='true')]" mode="handle-asserts" /></ol>
</xsl:if>
<xsl:if test="sch:rule/sch:report">
<p>To conform to this clause, an application should report the following cases:</p>
<ol><xsl:apply-templates select="sch:rule[not(@abstract='true')]" mode="handle-reports" /></ol>
</xsl:if>
</clause>
</xsl:template>
<!-- PHASE -->
<xsl:template match="sch:phase">
<!-- Phases are turned into conformance settings -->
<clause id="{concat('schematron-derived-annex-conform-', @id)}"><title><xsl:value-of select="@id"/></title>
<p>A document conforms to this clause if the following clauses are
satisfied:</p>
<ul>
<xsl:apply-templates />
</ul>
</clause>
</xsl:template>
<!-- RULE -->
<xsl:template match="sch:rule" />
<xsl:template match="sch:rule[@abstract='true']" mode="handle-asserts">
<xsl:param name="context">UNKNOWN</xsl:param>
<xsl:apply-templates select="sch:assert | sch:extends" mode="handle-asserts" >
<xsl:with-param name="context" select="$context" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="sch:rule[@abstract='true']" mode="handle-reports">
<xsl:param name="context">UNKNOWN</xsl:param>
<xsl:apply-templates select="sch:report | sch:extends " mode="handle-reports" >
<xsl:with-param name="context" select="$context" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="sch:rule[not(@abstract='true')]" mode="handle-asserts">
<xsl:apply-templates select="sch:assert | sch:extends" mode="handle-asserts" />
</xsl:template>
<xsl:template match="sch:rule[not(@abstract='true')]" mode="handle-reports">
<xsl:apply-templates select="sch:report | sch:extends " mode="handle-reports" />
</xsl:template>
<!-- SPAN -->
<xsl:template match="sch:title/sch:span" priority="1">
<code><xsl:apply-templates /></code>
</xsl:template>
<xsl:template match="sch:span">
<xsl:element name="{@class}"><xsl:apply-templates /></xsl:element>
</xsl:template>
<!-- TITLE -->
<xsl:template match="sch:title">
<title ><xsl:apply-templates /></title>
</xsl:template>
<!-- VALUE-OF -->
<xsl:template match="sch:value-of[ancestor::sch:pattern[@abstract='true']]" priority="1">
<code><i><xsl:value-of select="@select" /></i></code>
</xsl:template>
<xsl:template match="sch:value-of">
<code><xsl:value-of select="@select" /></code>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,819 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:src="http://purl.oclc.org/dsdl/9573-11amd1/ns/structure/1.0"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="stdex_front.xsl" />
<xsl:import href="stdex_toc.xsl" />
<xsl:import href="stdex_back.xsl" />
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0//EN" encoding="UTF-8" />
<!-- XSLT stylesheet for ISO/IEC stdex.rnc -->
<!-- version.0.51 -->
<xsl:template match="/">
<!-- contents: { document } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="/src:document">
<!-- contents: { head, body } -->
<html>
<head>
<title>ISO/IEC IT --- Ver.0.50 ---</title>
</head>
<link rel="stylesheet" href="stdex.css" type="text/css" />
<body>
<xsl:call-template name="frontm" />
<hr />
<xsl:call-template name="toc" />
<hr />
<xsl:apply-templates />
<xsl:call-template name="backm" />
</body>
</html>
</xsl:template>
<xsl:template match="src:head">
<!-- contents: { organization & ... } -->
</xsl:template>
<xsl:template match="src:foreword">
<!-- contents: { block*, part-list? } -->
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Foreword</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Avant-propos</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">foreword</xsl:with-param>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</h1>
<xsl:apply-templates />
<hr />
</xsl:template>
<xsl:template match="src:part-list">
<!-- contents: { part+ } -->
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="src:part">
<!-- contents: { number, title } -->
<li>
<span class="italic">
<xsl:text>-&#160;Part&#160;</xsl:text>
<xsl:apply-templates select="src:number"/>
<xsl:text>:&#160;</xsl:text>
<xsl:apply-templates select="src:title"/>
</span>
</li>
</xsl:template>
<xsl:template match="src:part/src:number">
<!-- contents: { positive-integer } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:part/src:title">
<!-- contents: { text } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:introduction">
<!-- contents: { block } -->
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">introduction</xsl:with-param>
<xsl:with-param name="text">Introduction</xsl:with-param>
</xsl:call-template>
</h1>
<xsl:apply-templates />
<hr />
</xsl:template>
<xsl:template name="anchor-text">
<xsl:param name="anc" />
<xsl:param name="text" />
<span id="{$anc}">
<xsl:value-of select="$text" />
</span>
</xsl:template>
<xsl:template match="src:warning">
<!-- contents: { attlist.warning, p* } -->
<xsl:text>WARNING-</xsl:text>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:scope">
<!-- contents: { block } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" />
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Scope</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Domaine d'application</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', $text)" />
</xsl:call-template>
</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:conf">
<!-- contents: { titled-clause } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:normative-references">
<!-- contents: { block*, referenced-document+ } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" />
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Normative references</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>R&#233;f&#233;rences normatives</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', $text)" />
</xsl:call-template>
</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:referenced-document">
<!-- contents: { id, abbrev, title, field*, url } -->
<dl>
<dd>
<xsl:apply-templates />
</dd>
</dl>
</xsl:template>
<xsl:template match="src:abbrev">
<xsl:apply-templates />
<xsl:text>, </xsl:text>
</xsl:template>
<xsl:template match="src:referenced-document/src:title">
<span class="italic">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="src:terms-and-definitions">
<!-- contents: { terms-and-definitions-content } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" />
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Terms and definitions</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Termes, d&#233;finitions et symboles</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', $text)" />
</xsl:call-template>
</h1>
<dl>
<xsl:apply-templates />
</dl>
</xsl:template>
<xsl:template match="src:term-and-definition">
<!-- contents: { term, term*, definition, (example, note, warning)* } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:term-and-definition/src:term">
<!-- contents: { text } -->
<dt>
<xsl:apply-templates />
</dt>
</xsl:template>
<xsl:template match="src:term-and-definition/src:definition">
<!-- contents: { inline } -->
<dd>
<xsl:apply-templates />
</dd>
</xsl:template>
<xsl:template match="src:clause">
<!-- contents: { id, title, clause-content } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:clause/src:title">
<!-- contents: { text | code } -->
<xsl:variable name="level" select="count(ancestor::src:clause|ancestor::src:annex)" />
<xsl:variable name="nth">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:annex//src:clause" format="A.1" />
</xsl:when>
<xsl:otherwise>
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" format="1.1" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="h{$level}">
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', .)" />
</xsl:call-template>
</xsl:element>
</xsl:template>
<xsl:template match="src:annex">
<!-- contents: { id, @normative, title, clause-content } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:annex/src:title">
<!-- contents: { text | code } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:annex" format="A" />
</xsl:variable>
<h1 class="annex">
<xsl:text>Annex </xsl:text>
<xsl:value-of select="$nth" />
<br />
<xsl:choose>
<xsl:when test="../@normative = 'true'">
<xsl:text>(normative)</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>(informative)</xsl:text>
</xsl:otherwise>
</xsl:choose>
<br />
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="." />
</xsl:call-template>
</h1>
</xsl:template>
<xsl:template match="src:bibliography">
<!-- contents: { referenced-document+ } -->
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Bibliography</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Bibliographie</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">bibliography</xsl:with-param>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</h1>
<ol>
<xsl:apply-templates />
</ol>
</xsl:template>
<xsl:template match="src:bibliography/src:referenced-document">
<li>
<xsl:number format="[1] " />
<xsl:apply-templates />
</li>
</xsl:template>
<xsl:template match="src:index">
<!-- contents: { attlist.index, text } -->
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">index</xsl:with-param>
<xsl:with-param name="text">Index</xsl:with-param>
</xsl:call-template>
</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:p">
<!-- contents: { inline } -->
<p>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="src:ol">
<!-- contents: { li } -->
<ol>
<xsl:apply-templates />
</ol>
</xsl:template>
<xsl:template match="src:ol/src:li">
<!-- contents: { id, block+ } -->
<xsl:variable name="level" select="count(ancestor::src:ol) mod 3" />
<xsl:variable name="format">
<xsl:choose>
<xsl:when test="$level=1">
<xsl:text>a) </xsl:text>
</xsl:when>
<xsl:when test="$level=2">
<xsl:text>1) </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>i) </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<li>
<xsl:number format="{$format}" />
<xsl:apply-templates />
</li>
</xsl:template>
<xsl:template match="src:ul">
<!-- contents: { li } -->
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="src:ul/src:li">
<!-- contents: { block+ } -->
<xsl:variable name="level" select="count(ancestor::src:ul)" />
<xsl:choose>
<xsl:when test="$level=2">
<li>&#183; <xsl:apply-templates /></li>
</xsl:when>
<xsl:otherwise>
<li>- <xsl:apply-templates /></li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:notation-list">
<!-- contents: { notation-item+ } -->
<dl compact="1">
<xsl:apply-templates />
</dl>
</xsl:template>
<xsl:template match="src:notation-item">
<!-- contents: { notation, notation-definition } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:notation">
<!-- contents: { inline } -->
<dt>
<xsl:apply-templates />
</dt>
</xsl:template>
<xsl:template match="src:notation-definition">
<!-- contents: { p, (p | note)* } -->
<dd>
<xsl:apply-templates />
</dd>
</xsl:template>
<xsl:template match="src:example">
<!-- contents: { p+ } -->
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>EXAMPLE</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>EXEMPLE</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<p>
<xsl:value-of select="$text" />
<xsl:text> </xsl:text>
<xsl:if test="count(../src:xmp) &gt; 1">
<xsl:number level="single" count="src:xmp" format="1 " />
</xsl:if>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="src:note">
<!-- contents: { p+ } -->
<p class="note">
<xsl:text>NOTE&#160;&#160;</xsl:text>
<xsl:if test="count(../src:note) &gt; 1">
<xsl:number level="single" count="src:note" format="1 " />
</xsl:if>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="src:code">
<!-- contents: { text } -->
<code>
<xsl:apply-templates />
</code>
</xsl:template>
<xsl:template match="src:b">
<!-- contents: { text } -->
<b>
<xsl:apply-templates />
</b>
</xsl:template>
<xsl:template match="src:i">
<!-- contents: { text } -->
<span class="italic">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="src:u">
<!-- contents: { text } -->
<u>
<xsl:apply-templates />
</u>
</xsl:template>
<xsl:template match="src:sup">
<!-- contents: { text } -->
<sup>
<xsl:apply-templates />
</sup>
</xsl:template>
<xsl:template match="src:sub">
<!-- contents: { text } -->
<sub>
<xsl:apply-templates />
</sub>
</xsl:template>
<xsl:template match="src:var">
<!-- contents: { text } -->
<var>
<xsl:apply-templates />
</var>
</xsl:template>
<xsl:template match="src:This | src:this">
<!-- contents: { empty } -->
<!-- F: la pr&#233;sente Norme internationale -->
<xsl:choose>
<xsl:when test="/src:document/src:head/src:part-number">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:value-of select="local-name()"/>
<xsl:text> part of </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:value-of select="/src:document/src:head/src:organization"/>
<xsl:text> </xsl:text>
<xsl:value-of select="/src:document/src:head/src:document-number"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:value-of select="local-name()"/>
<xsl:value-of select="/src:document/src:head/src:document-type"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="local-name()='This'">
<xsl:text>La</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>la</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> pr&#233;sente </xsl:text>
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-type='International Standard'">
<xsl:text>Norme internationale</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:Xref | src:xref">
<xsl:variable name="to" select="@to" />
<xsl:for-each select="//src:*[@id=$to]">
<xsl:call-template name="xref-one" />
</xsl:for-each>
</xsl:template>
<xsl:template name="xref-one">
<xsl:choose>
<xsl:when test="self::src:figure">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:figure" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:figure" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="self::src:table">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:table" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:table" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="self::src:li">
<xsl:variable name="level" select="count(ancestor::src:ol) mod 3" />
<xsl:variable name="format">
<xsl:choose>
<xsl:when test="$level=1">
<xsl:text>a) </xsl:text>
</xsl:when>
<xsl:when test="$level=2">
<xsl:text>1) </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>i) </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:number format="{$format}" />
</xsl:when>
<xsl:when test="ancestor::src:clause">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" format="1.1 " />
</xsl:when>
<xsl:when test="self::src:referenced-document">
<xsl:value-of select="src:abbrev" />
</xsl:when>
<xsl:otherwise>
<xsl:number level="multiple" count="src:annex" format="A.1 " />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:firstterm">
<!-- contents: { text } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:strong">
<!-- contents: { text } -->
<strong>
<xsl:apply-templates />
</strong>
</xsl:template>
<xsl:template match="src:artwork">
<!-- contents: { attlist.artwork } -->
<img src="{@entity}.jpg" />
</xsl:template>
<xsl:template match="src:footnote">
<!-- contents: { id, (text | p)+ } -->
<xsl:element name="a">
<xsl:attribute name="onClick">
<xsl:text>alert('</xsl:text>
<xsl:call-template name="fn-mark" />
<xsl:apply-templates />
<xsl:text>')</xsl:text>
</xsl:attribute>
<sup>
<xsl:call-template name="fn-mark" />
</sup>
</xsl:element>
</xsl:template>
<xsl:template name="fn-mark">
<xsl:choose>
<xsl:when test="ancestor::src:figure">
<xsl:number level="single" count="src:fn" format="a) " />
</xsl:when>
<xsl:when test="ancestor::src:table">
<xsl:number level="single" count="src:fn" format="a) " />
</xsl:when>
<xsl:otherwise>
<xsl:number value="count(preceding::src:fn)-count(preceding::src:fn[ancestor::src:figure or
ancestor::src:table])+1" format="1) " />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:table">
<!-- contents: { @pgwide, title?, block+ } -->
<div align="center">
<xsl:apply-templates />
<br />
</div>
</xsl:template>
<xsl:template match="src:table/src:title">
<xsl:variable name="ref">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:table" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:table" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Table</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Tableau</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- caption -->
<b>
<span id="tab{$ref}">
<xsl:value-of select="concat($text, ' ', $ref)" /> &#8211; <xsl:value-of select="." />
</span>
</b>
<!-- /caption -->
</xsl:template>
<xsl:template match="src:figure">
<!-- contents: { @pgwide, title?, block+ } -->
<div align="center">
<xsl:apply-templates select="*[not(self::src:title)]"/>
<xsl:apply-templates select="src:title"/>
</div>
</xsl:template>
<xsl:template match="src:figure/src:title">
<xsl:variable name="ref">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:figure" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:figure" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div align="center">
<b>
<span id="fig{$ref}">
<xsl:text>Figure </xsl:text>
<xsl:value-of select="$ref" /> &#8211; <xsl:value-of select="." />
</span>
</b>
</div>
</xsl:template>
<xsl:template match="src:tabular">
<table>
<xsl:choose>
<xsl:when test="@frame=&quot;none&quot;" />
<xsl:otherwise>
<xsl:attribute name="border" />
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="src:tgroup">
<xsl:apply-templates select="src:colspec" />
<xsl:apply-templates select="src:thead" />
<xsl:apply-templates select="src:tbody" />
<xsl:apply-templates select="src:tfoot" />
<tr>
<td colspan="100">
<xsl:apply-templates select=".//src:note" />
</td>
</tr>
</xsl:template>
<xsl:template match="src:colspec" />
<xsl:template match="src:thead">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:tbody">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:tfoot">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:row">
<tr>
<xsl:choose>
<xsl:when test="parent::src:thead or parent::src:tfoot">
<xsl:attribute name="bgcolor">#d0d0d0</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="@valign">
<xsl:attribute name="valign">
<xsl:value-of select="@valign" />
</xsl:attribute>
</xsl:when>
<xsl:when test="parent::src:*[@valign]">
<xsl:attribute name="valign">
<xsl:value-of select="parent::src:*[@valign]/@valign" />
</xsl:attribute>
</xsl:when>
<xsl:when test="parent::src:thead">
<xsl:attribute name="valign">bottom</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="valign">top</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@align">
<xsl:attribute name="align">
<xsl:value-of select="@align" />
</xsl:attribute>
</xsl:when>
<xsl:when test="ancestor::src:*[@align]">
<xsl:attribute name="align">
<xsl:value-of select="ancestor::src:*[@align]/@align" />
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:apply-templates />
</tr>
</xsl:template>
<xsl:template match="src:entry">
<xsl:choose>
<xsl:when test="ancestor::src:thead">
<xsl:call-template name="ent">
<xsl:with-param name="tag">th</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="ent">
<xsl:with-param name="tag">td</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ent">
<xsl:param name="tag" />
<xsl:element name="{$tag}">
<xsl:if test="@valign">
<xsl:attribute name="valign">
<xsl:value-of select="@valign" />
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="@align">
<xsl:attribute name="align">
<xsl:value-of select="@align" />
</xsl:attribute>
</xsl:when>
<xsl:when test="ancestor::src:*[@align]">
<xsl:attribute name="align">
<xsl:value-of select="ancestor::src:*[@align]/@align" />
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:if test="@morerows">
<xsl:attribute name="rowspan">
<xsl:value-of select="@morerows + 1" />
</xsl:attribute>
</xsl:if>
<xsl:if test="@namest and @nameend">
<xsl:call-template name="colspan">
<xsl:with-param name="namest" select="@namest" />
<xsl:with-param name="nameend" select="@nameend" />
</xsl:call-template>
</xsl:if>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template name="colspan">
<xsl:param name="namest" />
<xsl:param name="nameend" />
<xsl:call-template name="colspan-sub">
<xsl:with-param name="numst">
<xsl:choose>
<xsl:when test="parent::src:row/preceding-sibling::src:colspec[@colname=$namest]">
<xsl:value-of
select="count(parent::src:row/preceding-sibling::src:colspec[@colname=$namest]/preceding-sibling::src:colspec)"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="count(ancestor::src:tgroup/child::src:colspec[@colname=$namest]/preceding-sibling::src:colspec)"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="numend">
<xsl:choose>
<xsl:when test="parent::src:row/preceding-sibling::src:colspec[@colname=$nameend]">
<xsl:value-of
select="count(parent::src:row/preceding-sibling::src:colspec[@colname=$nameend]/preceding-sibling::src:colspec)"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="count(ancestor::src:tgroup/child::src:colspec[@colname=$nameend]/preceding-sibling::src:colspec)"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="colspan-sub">
<xsl:param name="numst" />
<xsl:param name="numend" />
<xsl:attribute name="colspan">
<xsl:value-of select="$numend - $numst + 1" />
</xsl:attribute>
</xsl:template>
<xsl:template match="text()">
<xsl:if test="normalize-space(.)!=' '">
<xsl:value-of select="." />
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,475 @@
<?xml version="1.0"?>
<!-- EXPAND REFERENCES -->
<!-- Expand references to complexType, attributeGroup and group. -->
<!-- Expand equivalence group heads as choice groups -->
<!-- TODO: Handle redefine problem, if some overridden declarations have snuck in -->
<!-- TODO: This does not handle references to groups in different schemas ?-->
<!--
Programmers: Rick Jelliffe, Cheney Xin, Rahul Grewel
-->
<!--
The code was written under sponsorship of JSTOR The Scholarly Journal Archive
This code is also available under the GPL (v3. http://www.gnu.org/copyleft/gpl.html)
-->
<!--
Open Source Initiative OSI - The MIT License:Licensing
[OSI Approved License]
The MIT License
This code copyright 2007-2009 jointly and severally
Allette Systems Pty. Ltd. (www.allette.com.au),
Topologi Pty. Ltd. (www.topologi.com),
JSTOR (http://www.jstor.org/)
and Rick Jelliffe.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/TR/xpath-functions">
<xsl:output method="xml" encoding="UTF-8" indent="yes"
omit-xml-declaration="no"/>
<!-- ============================================================================= -->
<!-- ================SUBSTITUTION GROUPS========================================== -->
<!-- ============================================================================= -->
<!--
TODO: check up on substitutions across namespaces
-->
<xsl:template
match="xs:element[@abstract='true'][ancestor::xs:element]">
<xsl:comment>Abstract substitution group <xsl:value-of select="@name"/></xsl:comment>
<xs:choice>
<!-- the cardinality of the head becomes the cardinality of the choice group -->
<xsl:copy-of select="@minOccurs"/>
<xsl:copy-of select="@maxOccurs"/>
<xsl:copy-of select="namespace::node()"/>
<xsl:for-each select="//xs:element[not(ancestor::xs:element)]
[@name]
[@substitutionGroup=current()/@name]">
<xs:element ref="@name" />
</xsl:for-each>
</xs:choice>
</xsl:template>
<!-- Now handle the case of an non-abstract element which is the head of a substitution group
where the element is just a ref. -->
<xsl:template
match="xs:element[@ref]">
<xsl:variable name="substitutes" select="//xs:element[not(ancestor::xs:element)]
[@name]
[@substitutionGroup=current()/@ref]"/>
<xsl:choose>
<xsl:when test="$substitutes and parent::xs:choice">
<!-- there are substitutes and we are already in a choice group -->
<xsl:copy-of select="." />
<xsl:for-each select="$substitutes" >
<xs:element ref="{name()}" >
<!-- the cardinality of the head becomes the cardinality of the choice group -->
<xsl:copy-of select="@minOccurs"/>
<xsl:copy-of select="@maxOccurs"/>
</xs:element>
</xsl:for-each>
</xsl:when>
<xsl:when test="substitutes">
<!-- there are substitutes and we are not in a choice group -->
<xs:choice>
<xsl:copy-of select="." />
<xsl:for-each select="$substitutes" >
<xs:element ref="{name()}" >
<!-- the cardinality of the head becomes the cardinality of the choice group -->
<xsl:copy-of select="@minOccurs"/>
<xsl:copy-of select="@maxOccurs"/>
</xs:element>
</xsl:for-each>
</xs:choice>
</xsl:when>
<xsl:otherwise>
<!-- there are no substitutes, so just copy -->
<xsl:copy-of select = "."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- TODO: handle the case where an non-abstract element is the head of a substitution group
and the group has a name but not a type. -->
<xsl:template
match="xs:element[@name][not(@type)][ancestor::xs:element]">
<xsl:variable name="substitutes" select="//xs:element[not(ancestor::xs:element)]
[@name]
[@substitutionGroup=current()/@name]"/>
<xsl:choose>
<xsl:when test="$substitutes and parent::xs:choice">
<!-- there are substitutes and we are already in a choice group -->
<xsl:copy-of select="." />
<xsl:for-each select="$substitutes" >
<xs:element ref="{name()}" >
<!-- the cardinality of the head becomes the cardinality of the choice group -->
<xsl:copy-of select="@minOccurs"/>
<xsl:copy-of select="@maxOccurs"/>
</xs:element>
</xsl:for-each>
</xsl:when>
<xsl:when test="substitutes">
<!-- there are substitutes and we are not in a choice group -->
<xs:choice>
<xs:element ref="{name()}" >
<!-- the cardinality of the head becomes the cardinality of the choice group -->
<xsl:copy-of select="@minOccurs"/>
<xsl:copy-of select="@maxOccurs"/>
</xs:element>
<xsl:for-each select="$substitutes" >
<xs:element ref="{name()}" >
<!-- the cardinality of the head becomes the cardinality of the choice group -->
<xsl:copy-of select="@minOccurs"/>
<xsl:copy-of select="@maxOccurs"/>
</xs:element>
</xsl:for-each>
</xs:choice>
</xsl:when>
<xsl:otherwise>
<!-- there are no substitutes, so just copy -->
<xsl:copy-of select = "."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ============================================================================= -->
<!-- ================TYPE ATTRIBUTE=============================================== -->
<!-- ============================================================================= -->
<!-- dereference for element which has type attribute and found type defined before -->
<xsl:template
match="xs:element[@name][@type]"
priority="10" mode="deep">
<xsl:call-template name="handle-element-with-name-and-type" />
</xsl:template>
<xsl:template name="handle-element-with-name-and-type">
<xsl:choose>
<xsl:when test=" ancestor::xs:complexType[@name = current()/@type]" >
<!-- Reported PH
Workaround to prevent recursion: in the case where an element in a complexType
has the same type as the currently defined one: just swallow it.
TODO: need to figure out something better for this case.
-->
</xsl:when>
<!-- dereference for element which has type attribute and found type defined in the same schema -->
<xsl:when test="ancestor::xs:schema/xs:complexType[@name=current()/@type]">
<xs:element name="{@name}">
<xsl:for-each select="@*[name() != 'name' and name() != 'type']|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<!-- handle reference to complex type in same schema -->
<xsl:comment>Expanded from a reference to <xsl:value-of select="@type"/></xsl:comment>
<xsl:apply-templates
select="ancestor::xs:schema/xs:complexType[@name=current()/@type]"
mode="deep"/>
</xs:element>
</xsl:when>
<!-- dereference for element which has type and there is : inside the type means external schema reference -->
<!-- if it is a embedded xsd type, then don't expand it -->
<xsl:when test="contains(@type,':') and substring-before(@type,':') != 'xs' and substring-before(@type,':') != 'xsd' and substring-before(@type,':') != 'xsi'">
<xsl:variable name="prefix" select="substring-before(@type,':')"/>
<xsl:variable name="typename" select="substring-after(@type,':')"/>
<xsl:variable name="uri" select="namespace-uri-for-prefix($prefix,.)"/>
<xsl:comment>Found element who reference external complexType:: prefix=<xsl:value-of select="$prefix"/></xsl:comment>
<xsl:comment> typename=<xsl:value-of select="$typename"/> uri=<xsl:value-of select="$uri"/></xsl:comment>
<xsl:choose>
<!-- if found the complexType with the same name in that schema then replace it -->
<xsl:when
test="//xs:schema[@targetNamespace = $uri]/xs:complexType[@name=$typename]">
<xs:element name="{@name}">
<xsl:for-each select="@*[name() != 'name' and name() != 'type']|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates
select="//xs:schema[@targetNamespace = $uri]/xs:complexType[@name=$typename]"
mode="deep"/>
</xs:element>
</xsl:when>
<!-- otherwise just copy it over without any changes -->
<xsl:otherwise>
<xsl:copy>
<xsl:for-each select="@*|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="deep"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- can't find type reference, copy over it as original -->
<xsl:otherwise>
<xsl:copy>
<xsl:for-each select="@*|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="deep"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
<xsl:template match="xs:complexType[@ref]"
priority="10" mode="deep">
<xsl:comment>Expanded from a reference to <xsl:value-of select="@ref"/></xsl:comment>
<xsl:apply-templates select="ancestor::xs:schema/xs:complexType[@name=current()/@ref]" mode="deep"/>
</xsl:template>
-->
<!-- ============================================================================= -->
<!-- ================REMOVE GROUPS ETC============================================ -->
<!-- ============================================================================= -->
<xsl:template match="xs:group[@ref]" priority="10" mode="deep">
<xsl:choose>
<xsl:when test="contains(@ref,':')">
<xsl:variable name="prefix" select="substring-before(@ref,':')"/>
<xsl:variable name="typename" select="substring-after(@ref,':')"/>
<xsl:variable name="uri" select="namespace-uri-for-prefix($prefix,.)"/>
<xsl:comment>Found group who reference external group prefix= <xsl:value-of select="$prefix"/></xsl:comment>
<xsl:comment> typename= <xsl:value-of select="$typename"/> uri= <xsl:value-of select="$uri"/></xsl:comment>
<xsl:comment>Expanded from a reference to <xsl:value-of select="@ref"/></xsl:comment>
<xsl:choose>
<!-- handle group occurrence on reference by a synthetic sequence -->
<xsl:when test="@minOccurs or @maxOccurs">
<xs:sequence>
<xsl:if test="@minOccurs">
<xsl:attribute name="minOccurs"><xsl:value-of select="@minOccurs"/></xsl:attribute>
</xsl:if>
<xsl:if test="@maxOccurs">
<xsl:attribute name="maxOccurs"><xsl:value-of select="@maxOccurs"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates
select="//xs:schema[@targetNamespace = $uri]/xs:group[@name=@typename]"
mode="deep"/>
</xs:sequence>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="//xs:schema[@targetNamespace = $uri]/xs:group[@name=@typename]"
mode="deep"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:comment>Expanded from a reference to <xsl:value-of select="@ref"/></xsl:comment>
<xsl:choose>
<!-- handle group occurrence on reference by a synthetic sequence -->
<xsl:when test="@minOccurs or @maxOccurs">
<xs:sequence>
<xsl:if test="@minOccurs">
<xsl:attribute name="minOccurs"><xsl:value-of select="@minOccurs"/></xsl:attribute>
</xsl:if>
<xsl:if test="@maxOccurs">
<xsl:attribute name="maxOccurs"><xsl:value-of select="@maxOccurs"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates
select="ancestor::xs:schema/xs:group[@name=current()/@ref]"
mode="deep"/>
</xs:sequence>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="ancestor::xs:schema/xs:group[@name=current()/@ref]"
mode="deep"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="xs:attributeGroup[@ref]" priority="10" mode="deep">
<xsl:choose>
<xsl:when test="contains(@ref,':')">
<xsl:variable name="prefix" select="substring-before(@ref,':')"/>
<xsl:variable name="typename" select="substring-after(@ref,':')"/>
<xsl:variable name="uri" select="namespace-uri-for-prefix($prefix,.)"/>
<xsl:comment>Found attributeGroup who reference external group prefix= <xsl:value-of select="$prefix"/></xsl:comment>
<xsl:comment> typename= <xsl:value-of select="$typename"/> uri= <xsl:value-of select="$uri"/></xsl:comment>
<xsl:comment>Expanded from a reference to <xsl:value-of select="@ref"/></xsl:comment>
<xsl:apply-templates
select="//xs:schema[@targetNamespace = $uri]/xs:attributeGroup[@name=@typename]"
mode="deep"/>
</xsl:when>
<xsl:otherwise>
<xsl:comment>Expanded from a reference to <xsl:value-of select="@ref"/></xsl:comment>
<xsl:apply-templates
select="ancestor::xs:schema/xs:attributeGroup[@name=current()/@ref]"
mode="deep"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Groups get added, just their contents -->
<xsl:template match="xs:schema/xs:group[@name] "
priority="10" mode="deep">
<xsl:apply-templates mode="deep"/>
</xsl:template>
<!-- When expanding, remove the name attribute for validity -->
<xsl:template match="xs:schema/xs:complexType[@name] | xs:schema/xs:attributeGroup[@name]"
priority="10" mode="deep">
<xsl:copy>
<xsl:for-each select="@*[not(name()='name')] |namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="deep"/>
</xsl:copy>
</xsl:template>
<!-- Strip out global complex type declarations, group declarations, and attribute group declarations-->
<xsl:template
match="xs:schema/xs:complexType[@name] | xs:schema/xs:group[@name] | xs:schema/xs:attributeGroup[@name]"
priority="5">
<xsl:comment> <xsl:value-of select="@name"/> stripped out</xsl:comment>
</xsl:template>
<!-- ============================================================================= -->
<!-- ================EXTENSION==================================================== -->
<!-- ============================================================================= -->
<!-- TODO -->
<xsl:template match="xs:simpleContent/xs:extension" mode="deep">
<xsl:variable name="base-decl"
select="ancestor::xs:schema/xs:complexType[xs:simpleContent][@name=current()/@base] |
ancestor::xs:schema/xs:simpleType[@name=current()/@base]"/>
<xsl:variable name="simple-base" select="ancestor::xs:schema/xs:simpleType[@name=current()/@base]"/>
<xsl:variable name="complex-base" select="ancestor::xs:schema/xs:complexType[xs:simpleContent][@name=current()/@base]"/>
<xsl:choose>
<xsl:when test="$simple-base">
<xsl:variable name="rest" select="$simple-base/xs:restriction"/>
<xs:apply-templates select="$simple-base" mode="deep"/>
</xsl:when>
<xsl:when test="$complex-base">
<xsl:choose>
<xsl:when test="$complex-base/xs:simpleContent/xs:extension">
<xsl:apply-templates select="$complex-base" mode="deep"/>
<xsl:apply-templates select="xs:attribute | xs:attributeGroup" mode="deep"/>
</xsl:when>
<xsl:when test="$complex-base/xs:simpleContent/xs:restriction">
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- can't find base reference, copy over it as original -->
<xsl:otherwise>
<xsl:copy>
<xsl:for-each select="@*|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="deep"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- TODO: what if the base type also extends from another? need 2 modes - one for elem and one for attrib -->
<xsl:template match="xs:complexContent/xs:extension" mode="deep">
<xsl:variable name="base-decl" select="ancestor::xs:schema/xs:complexType[@name=current()/@base]"/>
<xsl:choose>
<xsl:when test="$base-decl">
<xs:sequence>
<xsl:apply-templates select="$base-decl/*[not(self::xs:attribute or self::xs:attributeGroup)]" mode="deep"/>
<xsl:apply-templates select="*[not(self::xs:attribute or self::xs:attributeGroup)]" mode="deep"/>
</xs:sequence>
<xsl:apply-templates select="$base-decl/(xs:attribute | xs:attributeGroup)" mode="deep"/>
<xsl:apply-templates select="xs:attribute | xs:attributeGroup" mode="deep"/>
</xsl:when>
<!-- can't find base reference, copy over it as original -->
<xsl:otherwise>
<xsl:copy>
<xsl:for-each select="@*|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="deep"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ============================================================================= -->
<!-- ================DEFAULT====================================================== -->
<!-- ============================================================================= -->
<!-- for children of schema (that are not matched above) switch mode and reprocess -->
<xsl:template match="xs:schema/*" priority="1">
<xsl:apply-templates mode="deep" select="."/>
</xsl:template>
<!-- copy everything else -->
<xsl:template match="schemas | namespace |xs:schema ">
<xsl:copy>
<xsl:for-each select="@*|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<!-- copy everything else -->
<xsl:template match="*" mode="deep">
<xsl:copy>
<xsl:for-each select="@*|namespace::node()">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates mode="deep"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8"?><?xar XSLT?>
<!--
OVERVIEW - iso_abstract_expand.xsl
This is a preprocessor for ISO Schematron, which implements abstract patterns.
It also
* extracts a particular schema using an ID, where there are multiple
schemas, such as when they are embedded in the same NVDL script
* allows parameter substitution inside @context, @test, @select, @path
* experimentally, allows parameter recognition and substitution inside
text (NOTE: to be removed, for compataibility with other implementations,
please do not use this)
This should be used after iso-dsdl-include.xsl and before the skeleton or
meta-stylesheet (e.g. iso-svrl.xsl) . It only requires XSLT 1.
Each kind of inclusion can be turned off (or on) on the command line.
-->
<!--
Open Source Initiative OSI - The MIT License:Licensing
[OSI Approved License]
This source code was previously available under the zlib/libpng license.
Attribution is polite.
The MIT License
Copyright (c) 2004-2010 Rick Jellife and Academia Sinica Computing Centre, Taiwan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!--
VERSION INFORMATION
2013-09-19 RJ
* Allow macro expansion in @path attributes, eg. for sch:name/@path
2010-07-10 RJ
* Move to MIT license
2008-09-18 RJ
* move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
2008-07-29 RJ
* Create. Pull out as distinct XSL in its own namespace from old iso_pre_pro.xsl
* Put everything in private namespace
* Rewrite replace_substring named template so that copyright is clear
2008-07-24 RJ
* correct abstract patterns so for correct names: param/@name and
param/@value
2007-01-12 RJ
* Use ISO namespace
* Use pattern/@id not pattern/@name
* Add Oliver Becker's suggests from old Schematron-love-in list for <copy>
* Add XT -ism?
2003 RJ
* Original written for old namespace
* http://www.topologi.com/resources/iso-pre-pro.xsl
-->
<xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
xmlns:iae="http://www.schematron.com/namespace/iae"
>
<xslt:param name="schema-id"></xslt:param>
<!-- Driver for the mode -->
<xsl:template match="/">
<xsl:apply-templates select="." mode="iae:go" />
</xsl:template>
<!-- ================================================================================== -->
<!-- Normal processing rules -->
<!-- ================================================================================== -->
<!-- Output only the selected schema -->
<xslt:template match="iso:schema" >
<xsl:if test="string-length($schema-id) =0 or @id= $schema-id ">
<xslt:copy>
<xslt:copy-of select="@*" />
<xslt:apply-templates mode="iae:go" />
</xslt:copy>
</xsl:if>
</xslt:template>
<!-- Strip out any foreign elements above the Schematron schema .
-->
<xslt:template match="*[not(ancestor-or-self::iso:*)]" mode="iae:go" >
<xslt:apply-templates mode="iae:go" />
</xslt:template>
<!-- ================================================================================== -->
<!-- Handle Schematron abstract pattern preprocessing -->
<!-- abstract-to-real calls
do-pattern calls
macro-expand calls
multi-macro-expand
replace-substring -->
<!-- ================================================================================== -->
<!--
Abstract patterns allow you to say, for example
<pattern name="htmlTable" is-a="table">
<param name="row" value="html:tr"/>
<param name="cell" value="html:td" />
<param name="table" value="html:table" />
</pattern>
For a good introduction, see Uche Ogbujii's article for IBM DeveloperWorks
"Discover the flexibility of Schematron abstract patterns"
http://www-128.ibm.com/developerworks/xml/library/x-stron.html
However, note that ISO Schematron uses @name and @value attributes on
the iso:param element, and @id not @name on the pattern element.
-->
<!-- Suppress declarations of abstract patterns -->
<xslt:template match="iso:pattern[@abstract='true']" mode="iae:go" >
<xslt:comment>Suppressed abstract pattern <xslt:value-of select="@id"/> was here</xslt:comment>
</xslt:template>
<!-- Suppress uses of abstract patterns -->
<xslt:template match="iso:pattern[@is-a]" mode="iae:go" >
<xslt:comment>Start pattern based on abstract <xslt:value-of select="@is-a"/></xslt:comment>
<xslt:call-template name="iae:abstract-to-real" >
<xslt:with-param name="caller" select="@id" />
<xslt:with-param name="is-a" select="@is-a" />
</xslt:call-template>
</xslt:template>
<!-- output everything else unchanged -->
<xslt:template match="*" priority="-1" mode="iae:go" >
<xslt:copy>
<xslt:copy-of select="@*" />
<xslt:apply-templates mode="iae:go"/>
</xslt:copy>
</xslt:template>
<!-- Templates for macro expansion of abstract patterns -->
<!-- Sets up the initial conditions for the recursive call -->
<xslt:template name="iae:macro-expand">
<xslt:param name="caller"/>
<xslt:param name="text" />
<xslt:call-template name="iae:multi-macro-expand">
<xslt:with-param name="caller" select="$caller"/>
<xslt:with-param name="text" select="$text"/>
<xslt:with-param name="paramNumber" select="1"/>
</xslt:call-template>
</xslt:template>
<!-- Template to replace the current parameter and then
recurse to replace subsequent parameters. -->
<xslt:template name="iae:multi-macro-expand">
<xslt:param name="caller"/>
<xslt:param name="text" />
<xslt:param name="paramNumber" />
<xslt:choose>
<xslt:when test="//iso:pattern[@id=$caller]/iso:param[ $paramNumber]">
<xslt:call-template name="iae:multi-macro-expand">
<xslt:with-param name="caller" select="$caller"/>
<xslt:with-param name="paramNumber" select="$paramNumber + 1"/>
<xslt:with-param name="text" >
<xslt:call-template name="iae:replace-substring">
<xslt:with-param name="original" select="$text"/>
<xslt:with-param name="substring"
select="concat('$', //iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@name)"/>
<xslt:with-param name="replacement"
select="//iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@value"/>
</xslt:call-template>
</xslt:with-param>
</xslt:call-template>
</xslt:when>
<xslt:otherwise><xslt:value-of select="$text" /></xslt:otherwise>
</xslt:choose>
</xslt:template>
<!-- generate the real pattern from an abstract pattern + parameters-->
<xslt:template name="iae:abstract-to-real" >
<xslt:param name="caller"/>
<xslt:param name="is-a" />
<xslt:for-each select="//iso:pattern[@id= $is-a]">
<xslt:copy>
<xslt:choose>
<xslt:when test=" string-length( $caller ) = 0">
<xslt:attribute name="id"><xslt:value-of select="concat( generate-id(.) , $is-a)" /></xslt:attribute>
</xslt:when>
<xslt:otherwise>
<xslt:attribute name="id"><xslt:value-of select="$caller" /></xslt:attribute>
</xslt:otherwise>
</xslt:choose>
<xslt:apply-templates select="*|text()" mode="iae:do-pattern" >
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
</xslt:apply-templates>
</xslt:copy>
</xslt:for-each>
</xslt:template>
<!-- Generate a non-abstract pattern -->
<xslt:template mode="iae:do-pattern" match="*">
<xslt:param name="caller"/>
<xslt:copy>
<xslt:for-each select="@*[name()='test' or name()='context' or name()='select' or name()='path' ]">
<xslt:attribute name="{name()}">
<xslt:call-template name="iae:macro-expand">
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
</xslt:call-template>
</xslt:attribute>
</xslt:for-each>
<xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select'][name()!='path']" />
<xsl:for-each select="node()">
<xsl:choose>
<!-- Experiment: replace macros in text as well, to allow parameterized assertions
and so on, without having to have spurious <iso:value-of> calls and multiple
delimiting.
NOTE: THIS FUNCTIONALITY WILL BE REMOVED IN THE FUTURE -->
<xsl:when test="self::text()">
<xslt:call-template name="iae:macro-expand">
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
</xslt:call-template>
</xsl:when>
<xsl:otherwise>
<xslt:apply-templates select="." mode="iae:do-pattern">
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
</xslt:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xslt:copy>
</xslt:template>
<!-- UTILITIES -->
<!-- Simple version of replace-substring function -->
<xslt:template name="iae:replace-substring">
<xslt:param name="original" />
<xslt:param name="substring" />
<xslt:param name="replacement" select="''"/>
<xsl:choose>
<xsl:when test="not($original)" />
<xsl:when test="not(string($substring))">
<xsl:value-of select="$original" />
</xsl:when>
<xsl:when test="contains($original, $substring)">
<xsl:variable name="before" select="substring-before($original, $substring)" />
<xsl:variable name="after" select="substring-after($original, $substring)" />
<xsl:value-of select="$before" />
<xsl:value-of select="$replacement" />
<!-- recursion -->
<xsl:call-template name="iae:replace-substring">
<xsl:with-param name="original" select="$after" />
<xsl:with-param name="substring" select="$substring" />
<xsl:with-param name="replacement" select="$replacement" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- no substitution -->
<xsl:value-of select="$original" />
</xsl:otherwise>
</xsl:choose>
</xslt:template>
</xslt:stylesheet>

View File

@@ -0,0 +1,559 @@
<?xml version="1.0" ?>
<!--
NOTE: Early code, probably does not work
-->
<!--
OVERVIEW - iso_crdl_expand.xsl
This is a preprocessor for ISO Schematron, which expands ISO CREPDL
(Character Repertoire Definition Language) properties into Schematron
assertions. The CRDL rules must be in property elements linked to
assertions.
The implementation below is aimed at following XPath2, to fit with XSLT2 implementation.
There is scope to add outputs for other regex dialects.
-->
<!--
VERSION INFORMATION
2010-04-22 RJ BETA
* Get going with complex Xpaths to match code point by codepoint
* Works on CDRL embedded in properties element.
2008-09-20 RJ
* Add XPath2 Regex code contributed by David Carlisle with thanks
2008-07-29 RJ
* Beta
-->
<!--
Open Source Initiative OSI - The MIT License:Licensing
[OSI Approved License]
The MIT License
This code copyright 2010 Rick Jelliffe.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!--
The code follows the method of Appendix L of the 2010 Committee Draft of the
updated ISO Schematron.
The following schema:
============================================================
<sch:rule context="/*">
<sch:assert test="true()" properties="iso8859-6alt">The document text should be ISO 8859-6</sch:assert>
</sch:rule>
...
<sch:property id="iso8859-6alt">
<union xmlns="http://purl.oclc.org/dsdl/crepdl/ns/structure/1.0" xml:id="iso8859-6alt" >
<char>\p{IsBasicLatin}</char>
<char>&#xA0;</char>
<char>&#xA4;</char>
<char>&#xAD;</char>
<char>&#x60C;</char>
<char>&#x61B;</char>
<char>&#x61F;</char>
<char>[&#x621;-&#x63A;]</char>
<char>[&#x640;-&#x652;]</char>
</union>
</sch:property>
============================================================
will be transformed to this Schematron schema assertion
============================================================
<sch:rule context="/*">
<iso:let
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:crdl="http://purl.oclc.org/dsdl/crepdl/ns/structure/1.0"
name=" badCharactersString "
value="( string-join(
distinct-values (
for $i in string-to-codepoints( . )
return for $c in codepoints-to-string( $i)
return if ( matches($c,'\p{IsBasicLatin}')&#xA;
or matches($c,' ')&#xA;
or matches($c,'¤')&#xA;
or matches($c,'­')&#xA;
or matches($c,'،')&#xA;
or matches($c,'؛')&#xA;
or matches($c,'؟')&#xA;
or matches($c,'[ء-غ]')&#xA;
or matches($c,'[ـ-ْ]') )
then &#34;&#34;
else $c ), &#34;&#34;) )"/>
<iso:assert
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:crdl="http://purl.oclc.org/dsdl/crepdl/ns/structure/1.0"
test="true() and not( string-length( $badCharactersString ))"
properties="iso8859-6alt"
>The text is ISO 8859-6: not <iso:value-of select="$badCharactersString"/>
</iso:assert>
</sch:rule>
============================================================
This assertion works by
* converting the input string into a sequence of codepoints
* converting each single codepoint back into a string
* testing that string (character) against the referenced CRDL and producing Y or N
Which gives a sequence of Y or N strings as long as the input string. So
* reduce it to only a sequence of the distinct values
* convert it to a string
* test that string for any 'N'
The reason for all this convolution is that XSLT2 does not seem to have a way to apply an AND function to a sequence of booleans. Hence the convoluted approach. I hope there is a better method.
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:crdl="http://purl.oclc.org/dsdl/crepdl/ns/structure/1.0"
>
<!-- First, enable or disable CRDL processing based on
whether this is XSLT2 and whether there are any elements.
-->
<xsl:template match="/" >
<xsl:choose>
<xsl:when test="//iso:properties/iso:property/crdl:* and
( //iso:schema[@queryBinding='xpath2' or
@queryBinding='xslt2'])">
<!-- ENABLE CRDL PROCESSING -->
<xsl:message>ENABLE CRDL PROCESSING</xsl:message>
<xsl:copy>
<xsl:apply-templates mode="add-crdl" />
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:if test=
"not(//iso:schema[@queryBinding='xpath2' or
@queryBinding='xslt2'])">
<xsl:message>Query Language Error: CRDL requires xpath2 or xslt2. Assertions not generated.</xsl:message>
</xsl:if>
<!-- DISABLE CRDL PROCESSING -->
<xsl:message>DISABLE CRDL PROCESSING</xsl:message>
<xsl:copy-of select="/" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- =================================================================== -->
<!-- Generate Regular Expression from CREPDL -->
<!-- Process document. Strip any CRDL from properties. Add assertions -->
<!-- for them. -->
<!-- =================================================================== -->
<xsl:template mode="add-crdl" priority="-1"
match="*" >
<xsl:message>COPY <xsl:value-of select=" name() "/></xsl:message>
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates mode="add-crdl" />
</xsl:copy>
</xsl:template>
<!-- Special treatment for asserts which have a properties
attribute, which contains a reference to a property that
contains crdl elements.
-->
<xsl:template match="iso:assert[@properties]
[//iso:property[contains(
concat( ' ', current()/@properties, ' '),
concat( ' ', @id, ' '))]
[crdl:*]]"
mode="add-crdl" >
<xsl:variable name="theRegexes">
<!-- handle-crdl-regex returns a sequence of elements,
each being regexes to be used in an assertion. -->
<xsl:call-template name="handle-crdl-regex" >
<xsl:with-param name="theProperties" select=" @properties "/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="theOriginalTest" >
<xsl:value-of select="@test" />
</xsl:variable>
<xsl:variable name="this" as=" element()" >
<xsl:copy-of select="." />
</xsl:variable>
<!-- first copy the current assertion -->
<xsl:for-each select=" $theRegexes ">
<xsl:message>ASSERT {{ <xsl:value-of select=" . " /> }}</xsl:message>
<iso:let name=" badCharactersString " >
<xsl:attribute name="value"
select=" concat(
'( string-join(
distinct-values (
for $i in string-to-codepoints( . )
return for $c in codepoints-to-string( $i)
return if ',
. ,
' then &quot;&quot; else $c ), &quot;&quot;) )'
) " />
</iso:let>
<iso:assert>
<xsl:attribute name="test"
select=" concat ( $theOriginalTest , ' and not( string-length( $badCharactersString ))')" />
<xsl:copy-of select="$this/@*[not(name() = 'test')]" />
<xsl:apply-templates mode="add-crdl" select=" $this/node() " />
<xsl:text>: not </xsl:text>
<iso:value-of select="$badCharactersString" />
</iso:assert>
</xsl:for-each>
</xsl:template >
<!-- Special treatment for reports which have a properties
attribute, which contains a reference to a property that
contains crdl elements.
-->
<xsl:template match="iso:report[@properties]
[//iso:property[contains(
concat( ' ', current()/@properties, ' '),
concat( ' ', @id, ' '))]
[crdl:*]]
"
mode="add-crdl" >
<xsl:variable name="theRegexes">
<!-- handle-crdl-regex returns a sequence of elements,
each being regexes to be used in an report. -->
<xsl:call-template name="handle-crdl-regex" >
<xsl:with-param name="theProperties" select=" @properties "/>
</xsl:call-template>
</xsl:variable>
<xsl:message>REPORT {{ <xsl:value-of select=" $theRegexes " /> }}</xsl:message>
<xsl:variable name="this" as=" element()">
<xsl:copy-of select="." />
</xsl:variable>
<xsl:variable name="theOriginalTest" >
<xsl:value-of select="@test" />
</xsl:variable>
<!-- first copy the current assertion -->
<xsl:for-each select=" $theRegexes ">
<iso:let name=" badCharactersString " >
<xsl:attribute name="value"
select=" concat(
'( string-join(
distinct-values (
for $i in string-to-codepoints( . )
return for $c in codepoints-to-string( $i)
return if ',
. ,
' then &quot;&quot; else $c ), &quot;&quot;) )'
) " />
</iso:let>
<iso:report>
<xsl:attribute name="test"
select=" concat ( $theOriginalTest, ' and not( string-length( $badCharactersString ))')" />
<xsl:copy-of select="$this/@*[not(name() = 'test')]" />
<xsl:apply-templates mode="add-crdl" select=" $this/node() " />
<xsl:text>: found </xsl:text>
<iso:value-of select="$badCharactersString" />
</iso:report>
</xsl:for-each>
</xsl:template >
<!-- swallow crdl elements -->
<xsl:template match="crdl:*" mode="add-crdl" />
<!-- ================================================================================== -->
<!-- Handle embedded ISO DSDL Part 7 crdl character repertoire elements in assertions -->
<!-- ================================================================================== -->
<!-- This is a simple non-conforming implementation of crdl. It converts a crdl schema inside a
Schematron property element into the corresponding assertion using XPath2 regular expressions.
It has the following limitations:
* Except for top-level intersections, the difference and intersection elements are just
treated as unions. This generates no false negatives, which is what we want from an open schema.
* The repertoire element does not work.
* The UCS version attributes are ignored
The usage is this:
* the crdl elements are children of iso:schema or iso:pattern
* the top-level crdl element has an xml:id attribute
* an assertion or report element may have an ext:crdl-type attribute which references a crdl element
* such an assert or report is treated as two (or more) asserts or reports, each with the same assertion text, but
with different tests: the explicit @test from Schematron, and the generated tests from the crdl elements.
E.g.
<iso:schema ...>
...
<iso:rule context="para/text()">
<iso:assert test="true()" properties="shiftJIS" >
The para element should only contain characters provided by shift JIS
</iso:assert>
</iso:rule>
...
<iso:properties>
<iso:property id="shiftJIS"
<crdl:ref href="shiftJIS.credpl" />
</iso:property>
...
</iso:properties>
...
</iso:schema>
The same model can be used for implementing XSD datatypes ( @ext:xsd-type) and DTTL datatypes (@ext:dttl-type).
-->
<!-- =================================================================== -->
<!-- Handles referencing schemas with an @ext:crdl-type reference -->
<!-- This is obsolete, and will be reimplemented using @properties -->
<!-- =================================================================== -->
<!-- This template generates the output assert statements, and generates the particular
regular expressions for the Xpath2 matches() function (in a mode crdl:xpath).
This allows us to have smaller regexes in some cases, because whereever the XPath is
a series of matches() functions connected by and, we can instead use multiple assert elements
at the output. -->
<xsl:template name="handle-crdl-regex">
<xsl:param name="theProperties" />
<xsl:message>PROPERTIES <xsl:value-of select=" $theProperties " /></xsl:message>
<xsl:choose>
<xsl:when test="//iso:property[contains(
concat( ' ', $theProperties, ' '),
concat( ' ', @id, ' '))]
/crdl:intersection" >
<xsl:message>INTERSECTION </xsl:message>
<!-- Top-level intersections are handled as multiple assertions -->
<xsl:for-each select="//iso:property[contains(
concat( ' ', $theProperties, ' '),
concat( ' ', @id, ' '))]
/crdl:intersection/*">
<regex>matches(., "^[<xsl:apply-templates select="." mode="crdl:xpath" />]*$")</regex>
</xsl:for-each>
</xsl:when>
<!-- NOT FINISHED -->
<xsl:when test="//iso:property[contains(
concat( ' ', $theProperties, ' '),
concat( ' ', @id, ' '))]
/crdl:difference">
<!-- Top-level differences are handled approximately -->
<xsl:message>DIFFERENCE </xsl:message>
<!-- So difference(A, B, C) is assert(A or B or C) and assert(not(A and B and C)) -->
<regex>not(<xsl:for-each select="//iso:property[contains(
concat( ' ', $theProperties, ' '),
concat( ' ', @id, ' '))]
/crdl:difference/*"
>matches($c, "^[<xsl:apply-templates select="." mode="crdl:xpath" />]*$")
<xsl:if test="position() != last()"> and </xsl:if>
</xsl:for-each>)</regex>
</xsl:when>
<xsl:when test="//iso:property[contains(
concat( ' ', $theProperties, ' '),
concat( ' ', @id, ' '))]
[crdl:*]">
<!-- Handle the type as a single assertions -->
<xsl:message>OTHER <xsl:value-of select="//iso:property[contains(
concat( ' ', $theProperties, ' '),
concat( ' ', @id, ' '))]
/crdl:*/name() "/> </xsl:message>
<regex> <xsl:apply-templates
select="//iso:property[contains(
concat( ' ', $theProperties, ' '),
concat( ' ', @id, ' '))]
/crdl:*" mode="crdl:xpath" /> </regex>
</xsl:when>
<xsl:otherwise>
<xsl:message>Programming Error or Limitation: CRDL case not handled </xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ==================================================================================== -->
<!-- crdl-xpath MODE generates regular expressions using the XPath2 regexes -->
<!-- Generate the contents of the regular expressions that implement the char rep testing -->
<!-- ==================================================================================== -->
<xsl:template mode="crdl:xpath" match="crdl:ref">
<!-- Insert subschema -->
<xsl:variable name="document-uri" select="substring-before(@href, '#')"/>
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
<xsl:choose>
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
<xsl:message>Impossible URL in crdl reference</xsl:message>
</xsl:when>
<xsl:when test="string-length( $document-uri ) != 0">
<xsl:apply-templates select="//crdl:*[@xml:id= $fragment-id ]" mode="crdl:xpath"/>
</xsl:when>
<xsl:when test="string-length( $fragment-id ) != 0">
<xsl:apply-templates select="document( $document-uri )//crdl:*[@xml:id= $fragment-id ]" mode="crdl:xpath"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="document( $document-uri )/*" mode="crdl:xpath"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="crdl:xpath" match="crdl:repertoire">
<!-- Dereference repertoires and insert -->
<!-- TODO: build some charreps in and make some parameter system to allow them -->
<xsl:message>Named character repertoires not supported in this version</xsl:message>
</xsl:template>
<!-- The following code courtesy of David Carlisle -->
<xsl:template match="crdl:union" mode="crdl:xpath">
<xsl:text>( </xsl:text>
<xsl:for-each select="*">
<xsl:apply-templates select="." mode="crdl:xpath"/>
<xsl:if test="position()!=last()"><xsl:text >
or </xsl:text></xsl:if>
</xsl:for-each>
<xsl:text> )</xsl:text>
</xsl:template>
<!-- The following code courtesy of David Carlisle -->
<xsl:template match="crdl:intersection" mode="crdl:xpath">
<xsl:text>( </xsl:text>
<xsl:for-each select="*">
<xsl:apply-templates select="." mode="crdl:xpath"/>
<xsl:if test="position()!=last()"><xsl:text >
and </xsl:text></xsl:if>
</xsl:for-each>
<xsl:text> )</xsl:text>
</xsl:template>
<!-- The following code courtesy of David Carlisle -->
<xsl:template match="crdl:difference" mode="crdl:xpath">
<xsl:text>( </xsl:text>
<xsl:apply-templates select="*[1]" mode="crdl:xpath"/>
<xsl:for-each select="*[position()!=1]">
<xsl:if test="position()=1">
and not( </xsl:if>
<xsl:apply-templates select="." mode="crdl:xpath"/>
<xsl:choose>
<xsl:when test="position()!=last()"><xsl:text >
or </xsl:text></xsl:when>
<xsl:otherwise> ) </xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text> )</xsl:text>
</xsl:template>
<!-- The following code courtesy of David Carlisle -->
<xsl:template match="crdl:char[not(*)]" mode="crdl:xpath">
<xsl:text>matches($c,'</xsl:text>
<xsl:value-of select="replace(.,'''','''''')"/>
<xsl:text>')</xsl:text>
</xsl:template>
<!--
Obsolete code. This code was to help convert between different regex syntaxes.
CREPDL now uses XSLT2 regex syntax, so we only need to worry about escaping
string delimiters.
<xsl:choose>
<xsl:when test=".='\'"><xsl:text>\\</xsl:text></xsl:when>
<xsl:when test=".='.'"><xsl:text>\.</xsl:text></xsl:when>
<xsl:when test=".='['"><xsl:text>\[</xsl:text></xsl:when>
<xsl:when test=".=']'"><xsl:text>\]</xsl:text></xsl:when>
<xsl:when test=".='-'"><xsl:text>\-</xsl:text></xsl:when>
<xsl:when test=".='('"><xsl:text>\(</xsl:text></xsl:when>
<xsl:when test=".=')'"><xsl:text>\)</xsl:text></xsl:when>
<xsl:when test=".=' '"><xsl:text>\s</xsl:text></xsl:when>
<xsl:when test=".=' '"><xsl:text>\t</xsl:text></xsl:when>
<xsl:when test=".='|'"><xsl:text>\|</xsl:text></xsl:when>
<xsl:when test=".='&amp;'"><xsl:text>\&amp;</xsl:text></xsl:when>
<xsl:otherwise>
<xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
-->
<xsl:template match="crdl:char[crdl:kernel]" mode="crdl:xpath">
<!-- Note: no hull processing because ??? -->
<xsl:text>matches($c,'</xsl:text>
<xsl:value-of select="replace(crdl:kernel,'''','''''')"/>
<xsl:text>')</xsl:text>
</xsl:template>
<!-- FIX THIS -->
<xsl:template mode="crdl:xpath" match="crdl:hull">
<xsl:text>^</xsl:text><xsl:value-of select="." /><xsl:text></xsl:text>
</xsl:template>
<xsl:template mode="crdl:xpath" match="*" priority="-1">
<xsl:comment>Unhandled element <xsl:value-of select="name(.)"/></xsl:comment>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,558 @@
<?xml version="1.0" ?>
<!--
ISO_SVRL_1.6 .xsl WARNING: Schematron 1.6 is obsolete use ISO Schematron
Implementation of Schematron Validation Report Language from ISO Schematron
ISO/IEC 19757 Document Schema Definition Languages (DSDL)
Part 3: Rule-based validation Schematron
Annex D: Schematron Validation Report Language
This ISO Standard is available free as a Publicly Available Specification in PDF from ISO.
Also see www.schematron.com for drafts and other information.
This implementation of SVRL is designed to run with the "Skeleton" implementation
of Schematron which Oliver Becker devised. The skeleton code provides a
Schematron implementation but with named templates for handling all output;
the skeleton provides basic templates for output using this API, but client
validators can be written to import the skeleton and override the default output
templates as required. (In order to understand this, you must understand that
a named template such as "process-assert" in this XSLT stylesheet overrides and
replaces any template with the same name in the imported skeleton XSLT file.)
The other important thing to understand in this code is that there are different
versions of the Schematron skeleton. These track the development of Schematron through
Schematron 1.5, Schematron 1.6 and now ISO Schematron. One only skeleton must be
imported. The code has templates for the different skeletons commented out for
convenience. ISO Schematron has a different namespace than Schematron 1.5 and 1.6;
so the ISO Schematron skeleton has been written itself with an optional import
statement to in turn import the Schematron 1.6 skeleton. This will allow you to
validate with schemas from either namespace.
History:
2008-08-11
* RJ Fix attribute/@select which saxon allows in XSLT 1
2008-08-07
* RJ Add output-encoding attribute to specify final encoding to use
* Alter allow-foreign functionality so that Schematron span, emph and dir elements make
it to the output, for better formatting and because span can be used to mark up
semantically interesting information embedded in diagnostics, which reduces the
need to extend SVRL itself
* Diagnostic-reference had an invalid attribute @id that duplicated @diagnostic: removed
2008-08-06
* RJ Fix invalid output: svrl:diagnostic-reference is not contained in an svrl:text
* Output comment to SVRL file giving filename if available (from command-line parameter)
2008-08-04
* RJ move sch: prefix to schold: prefix to prevent confusion (we want people to
be able to switch from old namespace to new namespace without changing the
sch: prefix, so it is better to keep that prefix completely out of the XSLT)
* Extra signature fixes (PH)
2008-08-03
* Repair missing class parameter on process-p
2008-07-31
* Update skeleton names
2007-04-03
* Add option generate-fired-rule (RG)
2007-02-07
* Prefer true|false for parameters. But allow yes|no on some old for compatability
* DP Diagnostics output to svrl:text. Diagnosis put out after assertion text.
* Removed non-SVRL elements and attributes: better handled as an extra layer that invokes this one
* Add more formal parameters
* Correct confusion between $schemaVersion and $queryBinding
* Indent
* Validate against RNC schemas for XSLT 1 and 2 (with regex tests removed)
* Validate output with UniversalTest.sch against RNC schema for ISO SVRL
2007-02-01
* DP. Update formal parameters of overriding named templates to handle more attributes.
* DP. Refactor handling of rich and linkable parameters to a named template.
2007-01-22
* DP change svrl:ns to svrl:ns-in-attribute-value
* Change default when no queryBinding from "unknown" to "xslt"
2007-01-18:
* Improve documentation
* KH Add command-line options to generate paths or not
* Use axsl:attribute rather than xsl:attribute to shut XSLT2 up
* Add extra command-line options to pass to the iso_schematron_skeleton
2006-12-01: iso_svrl.xsl Rick Jelliffe,
* update namespace,
* update phase handling,
* add flag param to process-assert and process-report & @ flag on output
2001: Conformance1-5.xsl Rick Jelliffe,
* Created, using the skeleton code contributed by Oliver Becker
-->
<!--
Derived from Conformance1-5.xsl.
Copyright (c) 2001, 2006 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.
-->
<!-- Ideas nabbed from schematrons by Francis N., Miloslav N. and David C. -->
<!-- The command-line parameters are:
phase NMTOKEN | "#ALL" (default) Select the phase for validation
allow-foreign "true" | "false" (default) Pass non-Schematron elements to the generated stylesheet
diagnose= true | false|yes|no Add the diagnostics to the assertion test in reports (yes|no are obsolete)
generate-paths=true|false|yes|no generate the @location attribute with XPaths (yes|no are obsolete)
sch.exslt.imports semi-colon delimited string of filenames for some EXSLT implementations
optimize "visit-no-attributes" Use only when the schema has no attributes as the context nodes
generate-fired-rule "true"(default) | "false" Generate fired-rule elements
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:schold="http://www.ascc.net/xml/schematron"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
>
<!-- Select the import statement and adjust the path as
necessary for your system.
-->
<xsl:import href="skeleton1-6_XT.xsl"/>
<!--
<xsl:import href="iso_schematron_skeleton_for_saxon.xsl"/>
<xsl:import href="iso_schematron_skeleton_for_xslt1.xsl"/>
<xsl:import href="iso_schematron_skeleton.xsl"/>
<xsl:import href="skeleton1-5.xsl"/>
<xsl:import href="skeleton1-6.xsl"/>
-->
<xsl:param name="diagnose">true</xsl:param>
<xsl:param name="phase">
<xsl:choose>
<!-- Handle Schematron 1.5 and 1.6 phases -->
<xsl:when test="//schold:schema/@defaultPhase">
<xsl:value-of select="//schold:schema/@defaultPhase"/>
</xsl:when>
<!-- Handle ISO Schematron phases -->
<xsl:when test="//iso:schema/@defaultPhase">
<xsl:value-of select="//iso:schema/@defaultPhase"/>
</xsl:when>
<xsl:otherwise>#ALL</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="allow-foreign">false</xsl:param>
<xsl:param name="generate-paths">true</xsl:param>
<xsl:param name="generate-fired-rule">true</xsl:param>
<xsl:param name="optimize" />
<!-- e.g. saxon file.xml file.xsl "sch.exslt.imports=.../string.xsl;.../math.xsl" -->
<xsl:param name="sch.exslt.imports"/>
<!-- Set the language code for messages -->
<xsl:param name="langCode">default</xsl:param>
<xsl:param name="output-encoding"/>
<!-- Set the default for schematron-select-full-path, i.e. the notation for svrl's @location-->
<xsl:param name="full-path-notation">1</xsl:param>
<!-- Experimental: If this file called, then must be generating svrl -->
<xsl:variable name="svrlTest" select="true()" />
<!-- ================================================================ -->
<xsl:template name="process-prolog">
<axsl:output method="xml" omit-xml-declaration="no" standalone="yes"
indent="yes">
<xsl:if test=" string-length($output-encoding) &gt; 0">
<xsl:attribute name="encoding"><xsl:value-of select=" $output-encoding" /></xsl:attribute>
</xsl:if>
</axsl:output>
</xsl:template>
<!-- Overrides skeleton.xsl -->
<xsl:template name="process-root">
<xsl:param name="title"/>
<xsl:param name="contents" />
<xsl:param name="queryBinding" >xslt1</xsl:param>
<xsl:param name="schemaVersion" />
<xsl:param name="id" />
<xsl:param name="version"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:schematron-output title="{$title}" schemaVersion="{$schemaVersion}" >
<xsl:if test=" string-length( normalize-space( $phase )) &gt; 0 and
not( normalize-space( $phase ) = '#ALL') ">
<axsl:attribute name="phase">
<xsl:value-of select=" $phase " />
</axsl:attribute>
</xsl:if>
<axsl:comment><axsl:value-of select="$archiveDirParameter"/> &#xA0;
<axsl:value-of select="$archiveNameParameter"/> &#xA0;
<axsl:value-of select="$fileNameParameter"/> &#xA0;
<axsl:value-of select="$fileDirParameter"/></axsl:comment>&#xA0;
<xsl:apply-templates mode="do-schema-p" />
<xsl:copy-of select="$contents" />
</svrl:schematron-output>
</xsl:template>
<xsl:template name="process-assert">
<xsl:param name="test"/>
<xsl:param name="diagnostics" />
<xsl:param name="id" />
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:failed-assert test="{$test}" >
<xsl:if test="string-length( $id ) &gt; 0">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $flag ) &gt; 0">
<axsl:attribute name="flag">
<xsl:value-of select=" $flag " />
</axsl:attribute>
</xsl:if>
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:call-template name='linkableParms'>
<xsl:with-param name="role" select="$role" />
<xsl:with-param name="subject" select="$subject"/>
</xsl:call-template>
<xsl:if test=" $generate-paths = 'true' or $generate-paths= 'yes' ">
<!-- true/false is the new way -->
<axsl:attribute name="location">
<axsl:apply-templates select="." mode="schematron-get-full-path"/>
</axsl:attribute>
</xsl:if>
<svrl:text>
<xsl:apply-templates mode="text" />
</svrl:text>
<xsl:if test="$diagnose = 'yes' or $diagnose= 'true' ">
<!-- true/false is the new way -->
<xsl:call-template name="diagnosticsSplit">
<xsl:with-param name="str" select="$diagnostics"/>
</xsl:call-template>
</xsl:if>
</svrl:failed-assert>
</xsl:template>
<xsl:template name="process-report">
<xsl:param name="id"/>
<xsl:param name="test"/>
<xsl:param name="diagnostics"/>
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:successful-report test="{$test}" >
<xsl:if test=" string-length( $id ) &gt; 0">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $flag ) &gt; 0">
<axsl:attribute name="flag">
<xsl:value-of select=" $flag " />
</axsl:attribute>
</xsl:if>
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:call-template name='linkableParms'>
<xsl:with-param name="role" select="$role" />
<xsl:with-param name="subject" select="$subject"/>
</xsl:call-template>
<xsl:if test=" $generate-paths = 'yes' or $generate-paths = 'true' ">
<!-- true/false is the new way -->
<axsl:attribute name="location">
<axsl:apply-templates select="." mode="schematron-get-full-path"/>
</axsl:attribute>
</xsl:if>
<svrl:text>
<xsl:apply-templates mode="text" />
</svrl:text>
<xsl:if test="$diagnose = 'yes' or $diagnose='true' ">
<!-- true/false is the new way -->
<xsl:call-template name="diagnosticsSplit">
<xsl:with-param name="str" select="$diagnostics"/>
</xsl:call-template>
</xsl:if>
</svrl:successful-report>
</xsl:template>
<xsl:template name="process-diagnostic">
<xsl:param name="id"/>
<!-- Rich parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:diagnostic-reference diagnostic="{$id}" >
<!--xsl:if test="string($id)">
<xsl:attribute name="id">
<xsl:value-of select="$id"/>
</xsl:attribute>
</xsl:if-->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:text>
</xsl:text>
<xsl:apply-templates mode="text"/>
</svrl:diagnostic-reference>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-dir" >
<xsl:param name="value" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-emph" >
<xsl:param name="class" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process-rule">
<xsl:param name="id"/>
<xsl:param name="context"/>
<xsl:param name="flag"/>
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<xsl:if test=" $generate-fired-rule = 'true'">
<svrl:fired-rule context="{$context}" >
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:if test=" string( $id )">
<xsl:attribute name="id">
<xsl:value-of select=" $id " />
</xsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $role ) &gt; 0">
<xsl:attribute name="role">
<xsl:value-of select=" $role " />
</xsl:attribute>
</xsl:if>
</svrl:fired-rule>
</xsl:if>
</xsl:template>
<xsl:template name="process-ns">
<xsl:param name="prefix"/>
<xsl:param name="uri"/>
<svrl:ns-prefix-in-attribute-values uri="{$uri}" prefix="{$prefix}" />
</xsl:template>
<xsl:template name="process-p">
<xsl:param name="icon"/>
<xsl:param name="class"/>
<xsl:param name="id"/>
<xsl:param name="lang"/>
<svrl:text>
<xsl:apply-templates mode="text"/>
</svrl:text>
</xsl:template>
<xsl:template name="process-pattern">
<xsl:param name="name"/>
<xsl:param name="id"/>
<xsl:param name="is-a"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:active-pattern >
<xsl:if test=" string( $id )">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string( $name )">
<axsl:attribute name="name">
<xsl:value-of select=" $name " />
</axsl:attribute>
</xsl:if>
<xsl:call-template name='richParms'>
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<!-- ?? report that this screws up iso:title processing -->
<xsl:apply-templates mode="do-pattern-p"/>
<!-- ?? Seems that this apply-templates is never triggered DP -->
<axsl:apply-templates />
</svrl:active-pattern>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-message" >
<xsl:param name="pattern"/>
<xsl:param name="role"/>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-span" >
<xsl:param name="class" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- =========================================================================== -->
<!-- processing rich parameters. -->
<xsl:template name='richParms'>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<!-- Process rich attributes. -->
<xsl:if test="string($space)">
<axsl:attribute name="xml:space">
<xsl:value-of select="$space"/>
</axsl:attribute>
</xsl:if>
<xsl:if test="string($lang)">
<axsl:attribute name="xml:lang">
<xsl:value-of select="$lang"/>
</axsl:attribute>
</xsl:if>
</xsl:template>
<!-- processing linkable parameters. -->
<xsl:template name='linkableParms'>
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- ISO SVRL has a role attribute to match the Schematron role attribute -->
<xsl:if test=" string($role )">
<axsl:attribute name="role">
<xsl:value-of select=" $role " />
</axsl:attribute>
</xsl:if>
<!-- ISO SVRL does not have a subject attribute to match the Schematron subject attribute.
Instead, the Schematron subject attribute is folded into the location attribute -->
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,605 @@
<?xml version="1.0" ?>
<!--
ISO_SVRL.xsl
Implementation of Schematron Validation Report Language from ISO Schematron
ISO/IEC 19757 Document Schema Definition Languages (DSDL)
Part 3: Rule-based validation Schematron
Annex D: Schematron Validation Report Language
This ISO Standard is available free as a Publicly Available Specification in PDF from ISO.
Also see www.schematron.com for drafts and other information.
This implementation of SVRL is designed to run with the "Skeleton" implementation
of Schematron which Oliver Becker devised. The skeleton code provides a
Schematron implementation but with named templates for handling all output;
the skeleton provides basic templates for output using this API, but client
validators can be written to import the skeleton and override the default output
templates as required. (In order to understand this, you must understand that
a named template such as "process-assert" in this XSLT stylesheet overrides and
replaces any template with the same name in the imported skeleton XSLT file.)
The other important thing to understand in this code is that there are different
versions of the Schematron skeleton. These track the development of Schematron through
Schematron 1.5, Schematron 1.6 and now ISO Schematron. One only skeleton must be
imported. The code has templates for the different skeletons commented out for
convenience. ISO Schematron has a different namespace than Schematron 1.5 and 1.6;
so the ISO Schematron skeleton has been written itself with an optional import
statement to in turn import the Schematron 1.6 skeleton. This will allow you to
validate with schemas from either namespace.
History:
2010-04-14
* Add command line parameter 'terminate' which will terminate on first failed
assert and (optionally) successful report.
2009-03-18
* Fix atrribute with space "see " which generates wrong name in some processors
2008-08-11
* RJ Fix attribute/@select which saxon allows in XSLT 1
2008-08-07
* RJ Add output-encoding attribute to specify final encoding to use
* Alter allow-foreign functionality so that Schematron span, emph and dir elements make
it to the output, for better formatting and because span can be used to mark up
semantically interesting information embedded in diagnostics, which reduces the
need to extend SVRL itself
* Diagnostic-reference had an invalid attribute @id that duplicated @diagnostic: removed
2008-08-06
* RJ Fix invalid output: svrl:diagnostic-reference is not contained in an svrl:text
* Output comment to SVRL file giving filename if available (from command-line parameter)
2008-08-04
* RJ move sch: prefix to schold: prefix to prevent confusion (we want people to
be able to switch from old namespace to new namespace without changing the
sch: prefix, so it is better to keep that prefix completely out of the XSLT)
* Extra signature fixes (PH)
2008-08-03
* Repair missing class parameter on process-p
2008-07-31
* Update skeleton names
2007-04-03
* Add option generate-fired-rule (RG)
2007-02-07
* Prefer true|false for parameters. But allow yes|no on some old for compatability
* DP Diagnostics output to svrl:text. Diagnosis put out after assertion text.
* Removed non-SVRL elements and attributes: better handled as an extra layer that invokes this one
* Add more formal parameters
* Correct confusion between $schemaVersion and $queryBinding
* Indent
* Validate against RNC schemas for XSLT 1 and 2 (with regex tests removed)
* Validate output with UniversalTest.sch against RNC schema for ISO SVRL
2007-02-01
* DP. Update formal parameters of overriding named templates to handle more attributes.
* DP. Refactor handling of rich and linkable parameters to a named template.
2007-01-22
* DP change svrl:ns to svrl:ns-in-attribute-value
* Change default when no queryBinding from "unknown" to "xslt"
2007-01-18:
* Improve documentation
* KH Add command-line options to generate paths or not
* Use axsl:attribute rather than xsl:attribute to shut XSLT2 up
* Add extra command-line options to pass to the iso_schematron_skeleton
2006-12-01: iso_svrl.xsl Rick Jelliffe,
* update namespace,
* update phase handling,
* add flag param to process-assert and process-report & @ flag on output
2001: Conformance1-5.xsl Rick Jelliffe,
* Created, using the skeleton code contributed by Oliver Becker
-->
<!--
Derived from Conformance1-5.xsl.
Copyright (c) 2001-2010 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.
-->
<!-- Ideas nabbed from schematrons by Francis N., Miloslav N. and David C. -->
<!-- The command-line parameters are:
phase NMTOKEN | "#ALL" (default) Select the phase for validation
allow-foreign "true" | "false" (default) Pass non-Schematron elements and rich markup to the generated stylesheet
diagnose= true | false|yes|no Add the diagnostics to the assertion test in reports (yes|no are obsolete)
generate-paths=true|false|yes|no generate the @location attribute with XPaths (yes|no are obsolete)
sch.exslt.imports semi-colon delimited string of filenames for some EXSLT implementations
optimize "visit-no-attributes" Use only when the schema has no attributes as the context nodes
generate-fired-rule "true"(default) | "false" Generate fired-rule elements
terminate= yes | no | true | false | assert Terminate on the first failed assertion or successful report
Note: whether any output at all is generated depends on the XSLT implementation.
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:schold="http://www.ascc.net/xml/schematron"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
>
<!-- Select the import statement and adjust the path as
necessary for your system.
If not XSLT2 then also remove svrl:active-pattern/@document="{document-uri()}" from process-pattern()
-->
<!--
<xsl:import href="iso_schematron_skeleton_for_saxon.xsl"/>
-->
<xsl:import href="iso_schematron_skeleton_for_xslt1.xsl"/>
<!--
<xsl:import href="iso_schematron_skeleton.xsl"/>
<xsl:import href="skeleton1-5.xsl"/>
<xsl:import href="skeleton1-6.xsl"/>
-->
<xsl:param name="diagnose" >true</xsl:param>
<xsl:param name="phase" >
<xsl:choose>
<!-- Handle Schematron 1.5 and 1.6 phases -->
<xsl:when test="//schold:schema/@defaultPhase">
<xsl:value-of select="//schold:schema/@defaultPhase"/>
</xsl:when>
<!-- Handle ISO Schematron phases -->
<xsl:when test="//iso:schema/@defaultPhase">
<xsl:value-of select="//iso:schema/@defaultPhase"/>
</xsl:when>
<xsl:otherwise>#ALL</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="allow-foreign" >false</xsl:param>
<xsl:param name="generate-paths" >true</xsl:param>
<xsl:param name="generate-fired-rule" >true</xsl:param>
<xsl:param name="optimize"/>
<xsl:param name="output-encoding" ></xsl:param>
<!-- e.g. saxon file.xml file.xsl "sch.exslt.imports=.../string.xsl;.../math.xsl" -->
<xsl:param name="sch.exslt.imports" />
<!-- Experimental: If this file called, then must be generating svrl -->
<xsl:variable name="svrlTest" select="true()" />
<!-- ================================================================ -->
<xsl:template name="process-prolog">
<axsl:output method="xml" omit-xml-declaration="no" standalone="yes"
indent="yes">
<xsl:if test=" string-length($output-encoding) &gt; 0">
<xsl:attribute name="encoding"><xsl:value-of select=" $output-encoding" /></xsl:attribute>
</xsl:if>
</axsl:output>
</xsl:template>
<!-- Overrides skeleton.xsl -->
<xsl:template name="process-root">
<xsl:param name="title"/>
<xsl:param name="contents" />
<xsl:param name="queryBinding" >xslt1</xsl:param>
<xsl:param name="schemaVersion" />
<xsl:param name="id" />
<xsl:param name="version"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:schematron-output title="{$title}" schemaVersion="{$schemaVersion}" >
<xsl:if test=" string-length( normalize-space( $phase )) &gt; 0 and
not( normalize-space( $phase ) = '#ALL') ">
<axsl:attribute name="phase">
<xsl:value-of select=" $phase " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" $allow-foreign = 'true'">
</xsl:if>
<xsl:if test=" $allow-foreign = 'true'">
<xsl:call-template name='richParms'>
<xsl:with-param name="fpi" select="$fpi" />
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
</xsl:if>
<axsl:comment><axsl:value-of select="$archiveDirParameter"/> &#xA0;
<axsl:value-of select="$archiveNameParameter"/> &#xA0;
<axsl:value-of select="$fileNameParameter"/> &#xA0;
<axsl:value-of select="$fileDirParameter"/></axsl:comment>
<xsl:apply-templates mode="do-schema-p" />
<xsl:copy-of select="$contents" />
</svrl:schematron-output>
</xsl:template>
<xsl:template name="process-assert">
<xsl:param name="test"/>
<xsl:param name="diagnostics" />
<xsl:param name="id" />
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:failed-assert test="{$test}" >
<xsl:if test="string-length( $id ) &gt; 0">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $flag ) &gt; 0">
<axsl:attribute name="flag">
<xsl:value-of select=" $flag " />
</axsl:attribute>
</xsl:if>
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:call-template name='linkableParms'>
<xsl:with-param name="role" select="$role" />
<xsl:with-param name="subject" select="$subject"/>
</xsl:call-template>
<xsl:if test=" $generate-paths = 'true' or $generate-paths= 'yes' ">
<!-- true/false is the new way -->
<axsl:attribute name="location">
<axsl:apply-templates select="." mode="schematron-get-full-path"/>
</axsl:attribute>
</xsl:if>
<svrl:text>
<xsl:apply-templates mode="text" />
</svrl:text>
<xsl:if test="$diagnose = 'yes' or $diagnose= 'true' ">
<!-- true/false is the new way -->
<xsl:call-template name="diagnosticsSplit">
<xsl:with-param name="str" select="$diagnostics"/>
</xsl:call-template>
</xsl:if>
</svrl:failed-assert>
<xsl:if test=" $terminate = 'yes' or $terminate = 'true' ">
<axsl:message terminate="yes">TERMINATING</axsl:message>
</xsl:if>
<xsl:if test=" $terminate = 'assert' ">
<axsl:message terminate="yes">TERMINATING</axsl:message>
</xsl:if>
</xsl:template>
<xsl:template name="process-report">
<xsl:param name="id"/>
<xsl:param name="test"/>
<xsl:param name="diagnostics"/>
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:successful-report test="{$test}" >
<xsl:if test=" string-length( $id ) &gt; 0">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $flag ) &gt; 0">
<axsl:attribute name="flag">
<xsl:value-of select=" $flag " />
</axsl:attribute>
</xsl:if>
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:call-template name='linkableParms'>
<xsl:with-param name="role" select="$role" />
<xsl:with-param name="subject" select="$subject"/>
</xsl:call-template>
<xsl:if test=" $generate-paths = 'yes' or $generate-paths = 'true' ">
<!-- true/false is the new way -->
<axsl:attribute name="location">
<axsl:apply-templates select="." mode="schematron-get-full-path"/>
</axsl:attribute>
</xsl:if>
<svrl:text>
<xsl:apply-templates mode="text" />
</svrl:text>
<xsl:if test="$diagnose = 'yes' or $diagnose='true' ">
<!-- true/false is the new way -->
<xsl:call-template name="diagnosticsSplit">
<xsl:with-param name="str" select="$diagnostics"/>
</xsl:call-template>
</xsl:if>
</svrl:successful-report>
<xsl:if test=" $terminate = 'yes' or $terminate = 'true' ">
<axsl:message terminate="yes">TERMINATING</axsl:message>
</xsl:if>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-dir" >
<xsl:param name="value" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process-diagnostic">
<xsl:param name="id"/>
<!-- Rich parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:diagnostic-reference diagnostic="{$id}" >
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:text>
</xsl:text>
<xsl:apply-templates mode="text"/>
</svrl:diagnostic-reference>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-emph" >
<xsl:param name="class" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process-rule">
<xsl:param name="id"/>
<xsl:param name="context"/>
<xsl:param name="flag"/>
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<xsl:if test=" $generate-fired-rule = 'true'">
<svrl:fired-rule context="{$context}" >
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:if test=" string( $id )">
<xsl:attribute name="id">
<xsl:value-of select=" $id " />
</xsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $role ) &gt; 0">
<xsl:attribute name="role">
<xsl:value-of select=" $role " />
</xsl:attribute>
</xsl:if>
</svrl:fired-rule>
</xsl:if>
</xsl:template>
<xsl:template name="process-ns">
<xsl:param name="prefix"/>
<xsl:param name="uri"/>
<svrl:ns-prefix-in-attribute-values uri="{$uri}" prefix="{$prefix}" />
</xsl:template>
<xsl:template name="process-p">
<xsl:param name="icon"/>
<xsl:param name="class"/>
<xsl:param name="id"/>
<xsl:param name="lang"/>
<svrl:text>
<xsl:apply-templates mode="text"/>
</svrl:text>
</xsl:template>
<xsl:template name="process-pattern">
<xsl:param name="name"/>
<xsl:param name="id"/>
<xsl:param name="is-a"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:active-pattern >
<xsl:if test=" string( $id )">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string( $name )">
<axsl:attribute name="name">
<xsl:value-of select=" $name " />
</axsl:attribute>
</xsl:if>
<xsl:call-template name='richParms'>
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<!-- ?? report that this screws up iso:title processing -->
<xsl:apply-templates mode="do-pattern-p"/>
<!-- ?? Seems that this apply-templates is never triggered DP -->
<axsl:apply-templates />
</svrl:active-pattern>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-message" >
<xsl:param name="pattern"/>
<xsl:param name="role"/>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-span" >
<xsl:param name="class" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- =========================================================================== -->
<!-- processing rich parameters. -->
<xsl:template name='richParms'>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<!-- Process rich attributes. -->
<xsl:if test=" $allow-foreign = 'true'">
<xsl:if test="string($fpi)">
<axsl:attribute name="fpi">
<xsl:value-of select="$fpi"/>
</axsl:attribute>
</xsl:if>
<xsl:if test="string($icon)">
<axsl:attribute name="icon">
<xsl:value-of select="$icon"/>
</axsl:attribute>
</xsl:if>
<xsl:if test="string($see)">
<axsl:attribute name="see">
<xsl:value-of select="$see"/>
</axsl:attribute>
</xsl:if>
</xsl:if>
<xsl:if test="string($space)">
<axsl:attribute name="xml:space">
<xsl:value-of select="$space"/>
</axsl:attribute>
</xsl:if>
<xsl:if test="string($lang)">
<axsl:attribute name="xml:lang">
<xsl:value-of select="$lang"/>
</axsl:attribute>
</xsl:if>
</xsl:template>
<!-- processing linkable parameters. -->
<xsl:template name='linkableParms'>
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- ISO SVRL has a role attribute to match the Schematron role attribute -->
<xsl:if test=" string($role )">
<axsl:attribute name="role">
<xsl:value-of select=" $role " />
</axsl:attribute>
</xsl:if>
<!-- ISO SVRL does not have a subject attribute to match the Schematron subject attribute.
Instead, the Schematron subject attribute is folded into the location attribute -->
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,684 @@
<?xml version="1.0" ?>
<!--
ISO_SVRL.xsl
Implementation of Schematron Validation Report Language from ISO Schematron
ISO/IEC 19757 Document Schema Definition Languages (DSDL)
Part 3: Rule-based validation Schematron
Annex D: Schematron Validation Report Language
This ISO Standard is available free as a Publicly Available Specification in PDF from ISO.
Also see www.schematron.com for drafts and other information.
This implementation of SVRL is designed to run with the "Skeleton" implementation
of Schematron which Oliver Becker devised. The skeleton code provides a
Schematron implementation but with named templates for handling all output;
the skeleton provides basic templates for output using this API, but client
validators can be written to import the skeleton and override the default output
templates as required. (In order to understand this, you must understand that
a named template such as "process-assert" in this XSLT stylesheet overrides and
replaces any template with the same name in the imported skeleton XSLT file.)
The other important thing to understand in this code is that there are different
versions of the Schematron skeleton. These track the development of Schematron through
Schematron 1.5, Schematron 1.6 and now ISO Schematron. One only skeleton must be
imported. The code has templates for the different skeletons commented out for
convenience. ISO Schematron has a different namespace than Schematron 1.5 and 1.6;
so the ISO Schematron skeleton has been written itself with an optional import
statement to in turn import the Schematron 1.6 skeleton. This will allow you to
validate with schemas from either namespace.
History:
2010-04-14
* Add command line parameter 'terminate' which will terminate on first failed
assert and (optionally) successful report.
2009-03-18
* Fix atrribute with space "see " which generates wrong name in some processors
* rename allow-foreign to allow-rich
2009-02-19
* RJ add experimental non-standard attribute active-pattern/@document which says which
document is being validated from that point to the next similar. This is to cope with the
experimental multi-document validation in the XSLT2 skeleton.
2008-08-19
* RJ Experimental: Handle property elements. NOTE: signature change for process-assert,
process-report and process-rule to add property.
2008-08-11
* RJ Fix attribute/@select which saxon allows in XSLT 1
2008-08-07
* RJ Add output-encoding attribute to specify final encoding to use
* Alter allow-foreign functionality so that Schematron span, emph and dir elements make
it to the output, for better formatting and because span can be used to mark up
semantically interesting information embedded in diagnostics, which reduces the
need to extend SVRL itself
* Diagnostic-reference had an invalid attribute @id that duplicated @diagnostic: removed
2008-08-06
* RJ Fix invalid output: svrl:diagnostic-reference is not contained in an svrl:text
* Output comment to SVRL file giving filename if available (from command-line parameter)
2008-08-04
* RJ move sch: prefix to schold: prefix to prevent confusion (we want people to
be able to switch from old namespace to new namespace without changing the
sch: prefix, so it is better to keep that prefix completely out of the XSLT)
* Extra signature fixes (PH)
2008-08-03
* Repair missing class parameter on process-p
2008-07-31
* Update skeleton names
2007-04-03
* Add option generate-fired-rule (RG)
2007-02-07
* Prefer true|false for parameters. But allow yes|no on some old for compatability
* DP Diagnostics output to svrl:text. Diagnosis put out after assertion text.
* Removed non-SVRL elements and attributes: better handled as an extra layer that invokes this one
* Add more formal parameters
* Correct confusion between $schemaVersion and $queryBinding
* Indent
* Validate against RNC schemas for XSLT 1 and 2 (with regex tests removed)
* Validate output with UniversalTest.sch against RNC schema for ISO SVRL
2007-02-01
* DP. Update formal parameters of overriding named templates to handle more attributes.
* DP. Refactor handling of rich and linkable parameters to a named template.
2007-01-22
* DP change svrl:ns to svrl:ns-in-attribute-value
* Change default when no queryBinding from "unknown" to "xslt"
2007-01-18:
* Improve documentation
* KH Add command-line options to generate paths or not
* Use axsl:attribute rather than xsl:attribute to shut XSLT2 up
* Add extra command-line options to pass to the iso_schematron_skeleton
2006-12-01: iso_svrl.xsl Rick Jelliffe,
* update namespace,
* update phase handling,
* add flag param to process-assert and process-report & @ flag on output
2001: Conformance1-5.xsl Rick Jelliffe,
* Created, using the skeleton code contributed by Oliver Becker
-->
<!--
Derived from Conformance1-5.xsl.
Copyright (c) 2001-2010 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.
-->
<!-- Ideas nabbed from schematrons by Francis N., Miloslav N. and David C. -->
<!-- The command-line parameters are:
phase NMTOKEN | "#ALL" (default) Select the phase for validation
allow-foreign "true" | "false" (default) Pass non-Schematron elements and rich markup to the generated stylesheet
diagnose= true | false|yes|no Add the diagnostics to the assertion test in reports (yes|no are obsolete)
property= true | false Experimental: Add properties to the assertion test in reports
generate-paths=true|false|yes|no generate the @location attribute with XPaths (yes|no are obsolete)
sch.exslt.imports semi-colon delimited string of filenames for some EXSLT implementations
optimize "visit-no-attributes" Use only when the schema has no attributes as the context nodes
generate-fired-rule "true"(default) | "false" Generate fired-rule elements
terminate= yes | no | true | false | assert Terminate on the first failed assertion or successful report
Note: whether any output at all is generated depends on the XSLT implementation.
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:schold="http://www.ascc.net/xml/schematron"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
>
<!-- Select the import statement and adjust the path as
necessary for your system.
-->
<xsl:import href="iso_schematron_skeleton_for_saxon.xsl"/>
<!--
<xsl:import href="iso_schematron_skeleton_for_xslt1.xsl"/>
<xsl:import href="iso_schematron_skeleton.xsl"/>
<xsl:import href="skeleton1-5.xsl"/>
<xsl:import href="skeleton1-6.xsl"/>
-->
<xsl:param name="diagnose">true</xsl:param>
<xsl:param name="property">true</xsl:param>
<xsl:param name="phase">
<xsl:choose>
<!-- Handle Schematron 1.5 and 1.6 phases -->
<xsl:when test="//schold:schema/@defaultPhase">
<xsl:value-of select="//schold:schema/@defaultPhase"/>
</xsl:when>
<!-- Handle ISO Schematron phases -->
<xsl:when test="//iso:schema/@defaultPhase">
<xsl:value-of select="//iso:schema/@defaultPhase"/>
</xsl:when>
<xsl:otherwise>#ALL</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="allow-foreign">false</xsl:param>
<xsl:param name="generate-paths">true</xsl:param>
<xsl:param name="generate-fired-rule">true</xsl:param>
<xsl:param name="optimize" />
<!-- e.g. saxon file.xml file.xsl "sch.exslt.imports=.../string.xsl;.../math.xsl" -->
<xsl:param name="sch.exslt.imports" />
<xsl:param name="terminate" >false</xsl:param>
<!-- Set the language code for messages -->
<xsl:param name="langCode">default</xsl:param>
<xsl:param name="output-encoding"/>
<!-- Set the default for schematron-select-full-path, i.e. the notation for svrl's @location-->
<xsl:param name="full-path-notation">1</xsl:param>
<!-- Experimental: If this file called, then must be generating svrl -->
<xsl:variable name="svrlTest" select="true()" />
<!-- ================================================================ -->
<xsl:template name="process-prolog">
<axsl:output method="xml" omit-xml-declaration="no" standalone="yes"
indent="yes">
<xsl:if test=" string-length($output-encoding) &gt; 0">
<xsl:attribute name="encoding"><xsl:value-of select=" $output-encoding" /></xsl:attribute>
</xsl:if>
</axsl:output>
</xsl:template>
<!-- Overrides skeleton.xsl -->
<xsl:template name="process-root">
<xsl:param name="title"/>
<xsl:param name="contents" />
<xsl:param name="queryBinding" >xslt1</xsl:param>
<xsl:param name="schemaVersion" />
<xsl:param name="id" />
<xsl:param name="version"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:schematron-output title="{$title}" schemaVersion="{$schemaVersion}" >
<xsl:if test=" string-length( normalize-space( $phase )) &gt; 0 and
not( normalize-space( $phase ) = '#ALL') ">
<axsl:attribute name="phase">
<xsl:value-of select=" $phase " />
</axsl:attribute>
</xsl:if>
<axsl:comment><axsl:value-of select="$archiveDirParameter"/> &#xA0;
<axsl:value-of select="$archiveNameParameter"/> &#xA0;
<axsl:value-of select="$fileNameParameter"/> &#xA0;
<axsl:value-of select="$fileDirParameter"/></axsl:comment>
<xsl:apply-templates mode="do-schema-p" />
<xsl:copy-of select="$contents" />
</svrl:schematron-output>
</xsl:template>
<xsl:template name="process-assert">
<xsl:param name="test"/>
<xsl:param name="diagnostics" />
<xsl:param name="properties" />
<xsl:param name="id" />
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:failed-assert test="{$test}" >
<xsl:if test="string-length( $id ) &gt; 0">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $flag ) &gt; 0">
<axsl:attribute name="flag">
<xsl:value-of select=" $flag " />
</axsl:attribute>
</xsl:if>
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:call-template name='linkableParms'>
<xsl:with-param name="role" select="$role" />
<xsl:with-param name="subject" select="$subject"/>
</xsl:call-template>
<xsl:if test=" $generate-paths = 'true' or $generate-paths= 'yes' ">
<!-- true/false is the new way -->
<axsl:attribute name="location">
<axsl:apply-templates select="." mode="schematron-select-full-path"/>
</axsl:attribute>
</xsl:if>
<svrl:text>
<xsl:apply-templates mode="text" />
</svrl:text>
<xsl:if test="$diagnose = 'yes' or $diagnose= 'true' ">
<!-- true/false is the new way -->
<xsl:call-template name="diagnosticsSplit">
<xsl:with-param name="str" select="$diagnostics"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$property= 'yes' or $property= 'true' ">
<!-- true/false is the new way -->
<xsl:call-template name="propertiesSplit">
<xsl:with-param name="str" select="$properties"/>
</xsl:call-template>
</xsl:if>
</svrl:failed-assert>
<xsl:if test=" $terminate = 'yes' or $terminate = 'true' ">
<axsl:message terminate="yes">TERMINATING</axsl:message>
</xsl:if>
<xsl:if test=" $terminate = 'assert' ">
<axsl:message terminate="yes">TERMINATING</axsl:message>
</xsl:if>
</xsl:template>
<xsl:template name="process-report">
<xsl:param name="id"/>
<xsl:param name="test"/>
<xsl:param name="diagnostics"/>
<xsl:param name="flag" />
<xsl:param name="properties"/>
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:successful-report test="{$test}" >
<xsl:if test=" string-length( $id ) &gt; 0">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $flag ) &gt; 0">
<axsl:attribute name="flag">
<xsl:value-of select=" $flag " />
</axsl:attribute>
</xsl:if>
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:call-template name='linkableParms'>
<xsl:with-param name="role" select="$role" />
<xsl:with-param name="subject" select="$subject"/>
</xsl:call-template>
<xsl:if test=" $generate-paths = 'yes' or $generate-paths = 'true' ">
<!-- true/false is the new way -->
<axsl:attribute name="location">
<axsl:apply-templates select="." mode="schematron-select-full-path"/>
</axsl:attribute>
</xsl:if>
<svrl:text>
<xsl:apply-templates mode="text" />
</svrl:text>
<xsl:if test="$diagnose = 'yes' or $diagnose='true' ">
<!-- true/false is the new way -->
<xsl:call-template name="diagnosticsSplit">
<xsl:with-param name="str" select="$diagnostics"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$property = 'yes' or $property='true' ">
<!-- true/false is the new way -->
<xsl:call-template name="propertiesSplit">
<xsl:with-param name="str" select="$properties"/>
</xsl:call-template>
</xsl:if>
</svrl:successful-report>
<xsl:if test=" $terminate = 'yes' or $terminate = 'true' ">
<axsl:message terminate="yes" >TERMINATING</axsl:message>
</xsl:if>
</xsl:template>
<xsl:template name="process-diagnostic">
<xsl:param name="id"/>
<!-- Rich parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:diagnostic-reference diagnostic="{$id}" >
<!--xsl:if test="string($id)">
<xsl:attribute name="id">
<xsl:value-of select="$id"/>
</xsl:attribute>
</xsl:if-->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:text>
</xsl:text>
<xsl:apply-templates mode="text"/>
</svrl:diagnostic-reference>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-dir" >
<xsl:param name="value" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-emph" >
<xsl:param name="class" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process-rule">
<xsl:param name="id"/>
<xsl:param name="context"/>
<xsl:param name="flag"/>
<xsl:param name="properties" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<xsl:if test=" $generate-fired-rule = 'true'">
<svrl:fired-rule context="{$context}" >
<xsl:if test=" string( $id )">
<xsl:attribute name="id">
<xsl:value-of select=" $id " />
</xsl:attribute>
</xsl:if>
<xsl:if test=" string-length( $role ) &gt; 0">
<xsl:attribute name="role">
<xsl:value-of select=" $role " />
</xsl:attribute>
</xsl:if>
<!-- Process rich attributes. -->
<xsl:call-template name="richParms">
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<xsl:if test="$property= 'yes' or $property= 'true' ">
<!-- true/false is the new way -->
<xsl:call-template name="propertiesSplit">
<xsl:with-param name="str" select="$properties"/>
</xsl:call-template>
</xsl:if>
</svrl:fired-rule>
</xsl:if>
</xsl:template>
<xsl:template name="process-ns">
<xsl:param name="prefix"/>
<xsl:param name="uri"/>
<svrl:ns-prefix-in-attribute-values uri="{$uri}" prefix="{$prefix}" />
</xsl:template>
<xsl:template name="process-p">
<xsl:param name="icon"/>
<xsl:param name="class"/>
<xsl:param name="id"/>
<xsl:param name="lang"/>
<svrl:text>
<xsl:apply-templates mode="text"/>
</svrl:text>
</xsl:template>
<xsl:template name="process-pattern">
<xsl:param name="name"/>
<xsl:param name="id"/>
<xsl:param name="is-a"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<svrl:active-pattern >
<axsl:attribute name="document">
<axsl:value-of select="document-uri(/)" />
</axsl:attribute><!-- If XSLT1 remove this -->
<xsl:if test=" string( $id )">
<axsl:attribute name="id">
<xsl:value-of select=" $id " />
</axsl:attribute>
</xsl:if>
<xsl:if test=" string( $name )">
<axsl:attribute name="name">
<xsl:value-of select=" $name " />
</axsl:attribute>
</xsl:if>
<xsl:call-template name='richParms'>
<xsl:with-param name="fpi" select="$fpi"/>
<xsl:with-param name="icon" select="$icon"/>
<xsl:with-param name="lang" select="$lang"/>
<xsl:with-param name="see" select="$see" />
<xsl:with-param name="space" select="$space" />
</xsl:call-template>
<!-- ?? report that this screws up iso:title processing -->
<xsl:apply-templates mode="do-pattern-p"/>
<!-- ?? Seems that this apply-templates is never triggered DP -->
<axsl:apply-templates />
</svrl:active-pattern>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-message" >
<xsl:param name="pattern"/>
<xsl:param name="role"/>
</xsl:template>
<!-- Overrides skeleton -->
<xsl:template name="process-span" >
<xsl:param name="class" />
<xsl:choose>
<xsl:when test=" $allow-foreign = 'true'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- =========================================================================== -->
<!-- processing rich parameters. -->
<xsl:template name='richParms'>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<!-- Process rich attributes. -->
<xsl:if test=" $allow-foreign = 'true'">
<xsl:if test="string($fpi)">
<axsl:attribute name="fpi">
<xsl:value-of select="$fpi "/>
</axsl:attribute>
</xsl:if>
<xsl:if test="string($icon)">
<axsl:attribute name="icon">
<xsl:value-of select="$icon"/>
</axsl:attribute>
</xsl:if>
<xsl:if test="string($see)">
<axsl:attribute name="see">
<xsl:value-of select="$see" />
</axsl:attribute>
</xsl:if>
</xsl:if>
<xsl:if test="string($space)">
<axsl:attribute name="xml:space">
<xsl:value-of select="$space"/>
</axsl:attribute>
</xsl:if>
<xsl:if test="string($lang)">
<axsl:attribute name="xml:lang">
<xsl:value-of select="$lang"/>
</axsl:attribute>
</xsl:if>
</xsl:template>
<!-- processing linkable parameters. -->
<xsl:template name='linkableParms'>
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- ISO SVRL has a role attribute to match the Schematron role attribute -->
<xsl:if test=" string($role )">
<axsl:attribute name="role">
<xsl:value-of select=" $role " />
</axsl:attribute>
</xsl:if>
<!-- ISO SVRL does not have a subject attribute to match the Schematron subject attribute.
Instead, the Schematron subject attribute is folded into the location attribute -->
</xsl:template>
<!-- ===================================================== -->
<!-- Extension API: -->
<!-- This allows the transmission of extra attributes on -->
<!-- rules, asserts, reports, diagnostics. -->
<!-- ===================================================== -->
<!-- Overrides skeleton EXPERIMENTAL -->
<!-- The $contents is for static contents, the $value is for dynamic contents -->
<xsl:template name="process-property">
<xsl:param name="id"/>
<xsl:param name="name"/>
<xsl:param name="value"/>
<xsl:param name="contents"/>
<svrl:property id="{$id}" >
<xsl:if test="$name">
<xsl:attribute name="name"><xsl:value-of select="$name"/></xsl:attribute>
</xsl:if>
<xsl:if test="$value">
<xsl:attribute name="value"><xsl:value-of select="$value"/></xsl:attribute>
</xsl:if>
<xsl:if test="$contents">
<xsl:copy-of select="$contents"/>
</xsl:if>
</svrl:property>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,795 @@
<?xml version="1.0"?><?xar XSLT?>
<!-- Skeleton Module for the Schematron 1.6 XML Schema Language.
WARNING: Schematron 1.6 is obsolete use ISO Schematron
http://www.ascc.net/xml/schematron/
Copyright (c) 2000,2001 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.
-->
<!--
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 2007-08-06 RJ
* update template formal parameters to run under SAXON
Version: 2003-02-20
* added <let> for upgrade to 1.6
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
* phases supported: command-line option phase=#ALL|...
* abstract rules
* compile-time error messages
* add utility routine generate-id-from-path
Contributors: Rick Jelliffe (original), Oliver Becker (architecture),
Miloslav Nic (diagnostic, phase, options), Ludwig Svenonius (abstract)
Uche Ogbuji (misc. bug fixes), Jim Ancona (SAXON workaround),
Francis Norton (generate-id-from-path)
XSLT versions tested and working as-is:
* SAXON
* Instant Saxon
* XT n.b. key() not available, will die
* MSXML4
* Oracle
XSLT versions tested and requires small workaround from you
* Sablotron does not support import, so merge meta-stylesheets by hand
* Xalan for Java 2.0 outputs wrong namespace URI, so alter by hand or script
* Xalan for C 1.0 has problem with key, so edit by hand. Find "KEY" below
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.
-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:sch="http://www.ascc.net/xml/schematron"
>
<!-- Note that this namespace is not version specific.
This program implements schematron 1.6 -->
<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
<!-- Category: top-level-element -->
<xsl:output method="xml" omit-xml-declaration="no" standalone="yes" indent="yes"/>
<xsl:param name="block"></xsl:param><!-- reserved -->
<xsl:param name="phase">
<xsl:choose>
<xsl:when test="//sch:schema/@defaultPhase">
<xsl:value-of select="//sch:schema/@defaultPhase"/>
</xsl:when>
<xsl:otherwise>#ALL</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="hiddenKey"> key </xsl:param><!-- workaround for Xalan4J 2.0 -->
<xsl:param name="output-encoding"/>
<xsl:param name="message-newline">true</xsl:param>
<!-- SCHEMA -->
<xsl:template match="sch:schema | schema">
<axsl:stylesheet version="1.0">
<xsl:for-each select="sch:ns | ns">
<xsl:attribute name="{concat(@prefix,':dummy-for-xmlns')}" namespace="{@uri}"/>
</xsl:for-each>
<xsl:if test="count(sch:title/* | title/* )">
<xsl:message>
<xsl:text>Warning: </xsl:text>
<xsl:value-of select="name(.)"/>
<xsl:text> must not contain any child elements</xsl:text>
</xsl:message>
</xsl:if>
<xsl:if test="not($phase = '#ALL')">
<xsl:if test="not(sch:phase[@id = $phase] | phase[@id = $phase])">
<xsl:message>Phase Error: no phase with name <xsl:value-of select="$phase"
/> has been defined.</xsl:message>
</xsl:if>
</xsl:if>
<!-- These parameters may contain strings with the name and directory of the file being
validated. For convenience, if the caller only has the information in a single string,
that string could be put in fileDirParameter. The archives parameters are available
for ZIP archives.
-->
<axsl:param name="archiveDirParameter" />
<axsl:param name="archiveNameParameter" />
<axsl:param name="fileNameParameter" />
<axsl:param name="fileDirParameter" />
<xsl:call-template name="process-prolog"/>
<!-- SCHEMATRON-FULL-PATH -->
<!-- utility routine for implementations -->
<axsl:template match="*|@*" mode="schematron-get-full-path">
<axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
<axsl:text>/</axsl:text>
<axsl:if test="count(. | ../@*) = count(../@*)">@</axsl:if>
<axsl:value-of select="name()"/>
<axsl:text>[</axsl:text>
<axsl:value-of select="1+count(preceding-sibling::*[name()=name(current())])"/>
<axsl:text>]</axsl:text>
</axsl:template>
<!-- GENERATE-ID-FROM-PATH -->
<!-- repeatable-id maker derived from Francis Norton's. -->
<!-- use this if you need generate ids in seperate passes,
because generate-id() is not guaranteed to produce the same
results each time -->
<!--
<axsl:template match="/" mode="generate-id-from-path"/>
<axsl:template match="text()" mode="generate-id-from-path">
<axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
<axsl:value-of select="concat('.text-', 1+count(preceding-sibling::text()), '-')"/>
</axsl:template>
<axsl:template match="comment()" mode="generate-id-from-path">
<axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
<axsl:value-of select="concat('.comment-', 1+count(preceding-sibling::comment()), '-')"/>
</axsl:template>
<axsl:template match="processing-instruction()" mode="generate-id-from-path">
<axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
<axsl:value-of
select="concat('.processing-instruction-', 1+count(preceding-sibling::processing-instruction()), '-')"/>
</axsl:template>
<axsl:template match="@*" mode="generate-id-from-path">
<axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
<axsl:value-of select="concat('.@', name())"/>
</axsl:template>
<axsl:template match="*" mode="generate-id-from-path" priority="-0.5">
<axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
<axsl:text>.</axsl:text>
<axsl:choose>
<axsl:when test="count(. | ../namespace::*) = count(../namespace::*)">
<axsl:value-of select="concat('.namespace::-',1+count(namespace::*),'-')"/>
</axsl:when>
<axsl:otherwise>
<axsl:value-of
select="concat('.',name(),'-',1+count(preceding-sibling::*[name()=name(current())]),'-')"/>
</axsl:otherwise>
</axsl:choose>
</axsl:template>
-->
<xsl:apply-templates mode="do-keys"
select="sch:pattern/sch:rule/sch:key | pattern/rule/key "/>
<axsl:template match="/">
<xsl:call-template name="process-root">
<xsl:with-param name="fpi" select="@fpi"/>
<xsl:with-param xmlns:sch="http://www.ascc.net/xml/schematron"
name="title" select="./sch:title | title"/>
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="icon" select="@icon"/>
<xsl:with-param name="lang" select="@xml:lang"/>
<xsl:with-param name="version" select="@version" />
<xsl:with-param name="schemaVersion" select="@schemaVersion" />
<xsl:with-param name="contents">
<xsl:apply-templates mode="do-all-patterns"/>
</xsl:with-param>
</xsl:call-template>
</axsl:template>
<xsl:apply-templates/>
<axsl:template match="text()" priority="-1">
<!-- strip characters -->
</axsl:template>
</axsl:stylesheet>
</xsl:template>
<!-- ACTIVE -->
<xsl:template match="sch:active | active">
<xsl:if test="not(@pattern)">
<xsl:message>Markup Error: no pattern attribute in &lt;active></xsl:message>
</xsl:if>
<!-- <xsl:if test="//sch:rule[@id = current()/@pattern]"> -->
<xsl:if test="not(//sch:pattern[@id = current()/@pattern])">
<xsl:message>Reference Error: the pattern "<xsl:value-of select="@pattern"
/>" has been activated but is not declared</xsl:message>
</xsl:if>
</xsl:template>
<!-- ASSERT and REPORT -->
<xsl:template match="sch:assert | assert">
<xsl:if test="not(@test)">
<xsl:message>Markup Error: no test attribute in &lt;assert></xsl:message>
</xsl:if>
<axsl:choose>
<axsl:when test="{@test}"/>
<axsl:otherwise>
<xsl:call-template name="process-assert">
<xsl:with-param name="role" select="@role"/>
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="test" select="normalize-space(@test)" />
<xsl:with-param name="icon" select="@icon"/>
<xsl:with-param name="subject" select="@subject"/>
<xsl:with-param name="diagnostics" select="@diagnostics"/>
</xsl:call-template>
</axsl:otherwise>
</axsl:choose>
</xsl:template>
<xsl:template match="sch:report | report">
<xsl:if test="not(@test)">
<xsl:message>Markup Error: no test attribute in &lt;report></xsl:message>
</xsl:if>
<axsl:if test="{@test}">
<xsl:call-template name="process-report">
<xsl:with-param name="role" select="@role"/>
<xsl:with-param name="test" select="normalize-space(@test)" />
<xsl:with-param name="icon" select="@icon"/>
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="subject" select="@subject"/>
<xsl:with-param name="diagnostics" select="@diagnostics"/>
</xsl:call-template>
</axsl:if>
</xsl:template>
<!-- DIAGNOSTIC -->
<xsl:template match="sch:diagnostic | diagnostic"
><xsl:if test="not(@id)"
><xsl:message>Markup Error: no id attribute in &lt;diagnostic></xsl:message
></xsl:if><xsl:call-template name="process-diagnostic">
<xsl:with-param name="id" select="@id" />
</xsl:call-template>
</xsl:template>
<!-- DIAGNOSTICS -->
<xsl:template match="sch:diagnostics | diagnostics"/>
<!-- DIR -->
<xsl:template match="sch:dir | dir" mode="text"
><xsl:call-template name="process-dir">
<xsl:with-param name="value" select="@value"/>
</xsl:call-template>
</xsl:template>
<!-- EMPH -->
<xsl:template match="sch:emph | emph" mode="text"
><xsl:call-template name="process-emph"/>
</xsl:template>
<!-- EXTENDS -->
<xsl:template match="sch:extends | extends">
<xsl:if test="not(@rule)"
><xsl:message>Markup Error: no rule attribute in &lt;extends></xsl:message
></xsl:if>
<xsl:if test="not(//sch:rule[@abstract='true'][@id= current()/@rule] )
and not(//rule[@abstract='true'][@id= current()/@rule])">
<xsl:message>Reference Error: the abstract rule "<xsl:value-of select="@rule"
/>" has been referenced but is not declared</xsl:message>
</xsl:if>
<xsl:call-template name="IamEmpty" />
<xsl:if test="//sch:rule[@id=current()/@rule]">
<xsl:apply-templates select="//sch:rule[@id=current()/@rule]"
mode="extends"/>
</xsl:if>
</xsl:template>
<!-- KEY -->
<!-- do we need something to test uniqueness too? -->
<!-- NOTE: if you get complaint about "key" here (e.g. Xalan4C 1.0) replace
"key" with "$hiddenKey" -->
<xsl:template match="sch:key | key" mode="do-keys" >
<xsl:if test="not(@name)">
<xsl:message>Markup Error: no name attribute in &lt;key></xsl:message>
</xsl:if>
<xsl:if test="not(@path)">
<xsl:message>Markup Error: no path attribute in &lt;key></xsl:message>
</xsl:if>
<xsl:call-template name="IamEmpty" />
<axsl:key match="{../@context}" name="{@name}" use="{@path}"/>
</xsl:template>
<xsl:template match="sch:key | key" /><!-- swallow -->
<!-- LET -->
<xsl:template match="sch:let | let" >
<xsl:choose>
<xsl:when test="parent::sch:schema or parent::schema ">
<!-- it is an error to have an empty param/@select because an XPath is expected -->
<axsl:param name="{@name}" >
<xsl:if test="string-length(@value) &gt; 0">
<xsl:attribute name="select"><xsl:value-of select="@value"/></xsl:attribute>
</xsl:if>
</axsl:param>
</xsl:when>
<xsl:otherwise>
<axsl:variable name="{@name}" select="{@value}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- NAME -->
<xsl:template match="sch:name | name" mode="text">
<axsl:text xml:space="preserve"> </axsl:text>
<xsl:if test="@path"
><xsl:call-template name="process-name">
<xsl:with-param name="name" select="concat('name(',@path,')')"/>
<!-- SAXON needs that instead of select="'name({@path})'" -->
</xsl:call-template>
</xsl:if>
<xsl:if test="not(@path)"
><xsl:call-template name="process-name">
<xsl:with-param name="name" select="'name(.)'"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="IamEmpty" />
<axsl:text xml:space="preserve"> </axsl:text>
</xsl:template>
<!-- NS -->
<xsl:template match="sch:ns | ns" mode="do-all-patterns" >
<xsl:if test="not(@uri)">
<xsl:message>Markup Error: no uri attribute in &lt;ns></xsl:message>
</xsl:if>
<xsl:if test="not(@prefix)">
<xsl:message>Markup Error: no prefix attribute in &lt;ns></xsl:message>
</xsl:if>
<xsl:call-template name="IamEmpty" />
<xsl:call-template name="process-ns" >
<xsl:with-param name="prefix" select="@prefix"/>
<xsl:with-param name="uri" select="@uri"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="sch:ns | ns" /><!-- swallow -->
<!-- P -->
<xsl:template match="sch:schema/sch:p | schema/p" mode="do-schema-p" >
<xsl:call-template name="process-p">
<xsl:with-param name="class" select="@class"/>
<xsl:with-param name="icon" select="@icon"/>
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="lang" select="@xml:lang"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="sch:pattern/sch:p | pattern/p" mode="do-pattern-p" >
<xsl:call-template name="process-p">
<xsl:with-param name="class" select="@class"/>
<xsl:with-param name="icon" select="@icon"/>
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="lang" select="@xml:lang"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="sch:phase/sch:p" /><!-- We don't use these -->
<xsl:template match="sch:p | p" />
<!-- PATTERN -->
<xsl:template match="sch:pattern | pattern" mode="do-all-patterns">
<xsl:if test="($phase = '#ALL')
or (../sch:phase[@id= ($phase)]/sch:active[@pattern= current()/@id])
or (../phase[@id= ($phase)]/active[@id= current()/@id])">
<xsl:call-template name="process-pattern">
<xsl:with-param name="name" select="@name"/>
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="see" select="@see"/>
<xsl:with-param name="fpi" select="@fpi"/>
<xsl:with-param name="icon" select="@icon"/>
</xsl:call-template>
<axsl:apply-templates select="/" mode="M{count(preceding-sibling::*)}"/>
</xsl:if>
</xsl:template>
<xsl:template match="sch:pattern | pattern">
<xsl:if test="($phase = '#ALL')
or (../sch:phase[@id= ($phase)]/sch:active[@pattern= current()/@id])
or (../phase[@id= ($phase)]/active[@id= current()/@id])">
<xsl:apply-templates/>
<axsl:template match="text()" priority="-1" mode="M{count(preceding-sibling::*)}">
<!-- strip characters -->
</axsl:template>
</xsl:if>
</xsl:template>
<!-- PHASE -->
<xsl:template match="sch:phase | phase" >
<xsl:if test="not(@id)">
<xsl:message>Markup Error: no id attribute in &lt;phase></xsl:message>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<!-- RULE -->
<xsl:template match="sch:rule[not(@abstract='true')] | rule[not(@abstract='true')]">
<xsl:if test="not(@context)">
<xsl:message>Markup Error: no context attribute in &lt;rule></xsl:message>
</xsl:if>
<axsl:template match="{@context}"
priority="{4000 - count(preceding-sibling::*)}" mode="M{count(../preceding-sibling::*)}">
<xsl:call-template name="process-rule">
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="context" select="@context"/>
<xsl:with-param name="role" select="@role"/>
</xsl:call-template>
<xsl:apply-templates/>
<axsl:apply-templates mode="M{count(../preceding-sibling::*)}"/>
</axsl:template>
</xsl:template>
<!-- ABSTRACT RULE -->
<xsl:template match="sch:rule[@abstract='true'] | rule[@abstract='true']" >
<xsl:if test=" not(@id)">
<xsl:message>Markup Error: no id attribute on abstract &lt;rule></xsl:message>
</xsl:if>
<xsl:if test="@context">
<xsl:message>Markup Error: (2) context attribute on abstract &lt;rule></xsl:message>
</xsl:if>
</xsl:template>
<xsl:template match="sch:rule[@abstract='true'] | rule[@abstract='true']"
mode="extends" >
<xsl:if test="@context">
<xsl:message>Markup Error: context attribute on abstract &lt;rule></xsl:message>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<!-- SPAN -->
<xsl:template match="sch:span | span" mode="text">
<xsl:call-template name="process-span"
><xsl:with-param name="class" select="@class"/>
</xsl:call-template>
</xsl:template>
<!-- TITLE -->
<!-- swallow -->
<xsl:template match="sch:title | title" />
<!-- VALUE-OF -->
<xsl:template match="sch:value-of | value-of" mode="text" >
<xsl:if test="not(@select)">
<xsl:message>Markup Error: no select attribute in &lt;value-of></xsl:message>
</xsl:if>
<xsl:call-template name="IamEmpty" />
<axsl:text xml:space="preserve"> </axsl:text>
<xsl:choose>
<xsl:when test="@select"
><xsl:call-template name="process-value-of">
<xsl:with-param name="select" select="@select"/>
<!-- will saxon have problem with this too?? -->
</xsl:call-template>
</xsl:when>
<xsl:otherwise >
<xsl:call-template name="process-value-of"
><xsl:with-param name="select" select="'.'"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<axsl:text xml:space="preserve"> </axsl:text>
</xsl:template>
<!-- ============================================================== -->
<!-- Text -->
<xsl:template match="text()" priority="-1" mode="do-keys">
<!-- strip characters -->
</xsl:template>
<xsl:template match="text()" priority="-1" mode="do-all-patterns">
<!-- strip characters -->
</xsl:template>
<xsl:template match="text()" priority="-1" mode="do-schema-p">
<!-- strip characters -->
</xsl:template>
<xsl:template match="text()" priority="-1" mode="do-pattern-p">
<!-- strip characters -->
</xsl:template>
<xsl:template match="text()" priority="-1">
<!-- strip characters -->
</xsl:template>
<xsl:template match="text()" mode="text">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
<xsl:template match="text()" mode="inline-text">
<xsl:value-of select="."/>
</xsl:template>
<!-- ============================================================== -->
<!-- utility templates -->
<xsl:template name="IamEmpty">
<xsl:if test="count( * )">
<xsl:message>
<xsl:text>Warning: </xsl:text>
<xsl:value-of select="name(.)"/>
<xsl:text> must not contain any child elements</xsl:text>
</xsl:message>
</xsl:if>
</xsl:template>
<xsl:template name="diagnosticsSplit">
<!-- Process at the current point the first of the <diagnostic> elements
referred to parameter str, and then recurse -->
<xsl:param name="str"/>
<xsl:variable name="start">
<xsl:choose>
<xsl:when test="contains($str,' ')">
<xsl:value-of select="substring-before($str,' ')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$str"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="end">
<xsl:if test="contains($str,' ')">
<xsl:value-of select="substring-after($str,' ')"/>
</xsl:if>
</xsl:variable>
<xsl:if test="not(string-length(normalize-space($start)) = 0)
and not(//sch:diagnostic[@id = ($start)]) and not(//diagnostic[@id = ($start)])">
<xsl:message>Reference error: A diagnostic "<xsl:value-of select="string($start)"
/>" has been referenced but is not declared</xsl:message>
</xsl:if>
<xsl:if test="string-length(normalize-space($start)) > 0">
<xsl:apply-templates
select="//sch:diagnostic[@id = ($start) ] | //diagnostic[@id= ($start) ]"/>
</xsl:if>
<xsl:if test="not($end='')">
<xsl:call-template name="diagnosticsSplit">
<xsl:with-param name="str" select="$end"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- ============================================================== -->
<xsl:template match="*">
<xsl:message>
<xsl:text>Warning: unrecognized element </xsl:text>
<xsl:value-of select="name(.)"/>
</xsl:message>
</xsl:template>
<xsl:template match="*" mode="text">
<xsl:message>
<xsl:text>Warning: unrecognized element </xsl:text>
<xsl:value-of select="name(.)"/>
</xsl:message>
</xsl:template>
<!-- ============================================================== -->
<!-- DEFAULT NAMED TEMPLATES -->
<!-- These are the actions that are performed unless overridden -->
<!-- ============================================================== -->
<xsl:template name="process-prolog"/>
<!-- no params -->
<xsl:template name="process-root">
<xsl:param name="contents"/>
<xsl:param name="id" />
<xsl:param name="version" />
<xsl:param name="schemaVersion" />
<xsl:param name="queryBinding" />
<xsl:param name="title" />
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<xsl:copy-of select="$contents"/>
</xsl:template>
<xsl:template name="process-assert">
<xsl:param name="test"/>
<xsl:param name="diagnostics" />
<xsl:param name="id" />
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<xsl:call-template name="process-message">
<xsl:with-param name="pattern" select="$test"/>
<xsl:with-param name="role" select="$role"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="process-report">
<xsl:param name="test"/>
<xsl:param name="diagnostics" />
<xsl:param name="id" />
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<xsl:call-template name="process-message">
<xsl:with-param name="pattern" select="$test"/>
<xsl:with-param name="role" select="$role"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="process-diagnostic">
<xsl:param name="id" />
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="text"/>
<axsl:text> </axsl:text>
</xsl:template>
<xsl:template name="process-dir">
<xsl:param name="value" />
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:template>
<xsl:template name="process-emph">
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:template>
<xsl:template name="process-name">
<xsl:param name="name"/>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<axsl:value-of select="{$name}"/>
<axsl:text> </axsl:text>
</xsl:template>
<xsl:template name="process-ns" >
<!-- Note that process-ns is for reporting. The sch:ns elements are
independently used in the sch:schema template to provide namespace bindings -->
<xsl:param name="prefix"/>
<xsl:param name="uri" />
</xsl:template>
<xsl:template name="process-p">
<xsl:param name="id" />
<xsl:param name="class" />
<xsl:param name="icon" />
<xsl:param name="lang" />
</xsl:template>
<xsl:template name="process-pattern">
<xsl:param name="id" />
<xsl:param name="name" />
<xsl:param name="is-a" />
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
</xsl:template>
<xsl:template name="process-rule">
<xsl:param name="context" />
<xsl:param name="id" />
<xsl:param name="flag" />
<!-- "Linkable" parameters -->
<xsl:param name="role"/>
<xsl:param name="subject"/>
<!-- "Rich" parameters -->
<xsl:param name="fpi" />
<xsl:param name="icon" />
<xsl:param name="lang" />
<xsl:param name="see" />
<xsl:param name="space" />
</xsl:template>
<xsl:template name="process-span" >
<xsl:param name="class" />
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<xsl:apply-templates mode="inline-text"/>
<axsl:text> </axsl:text>
</xsl:template>
<xsl:template name="process-title" >
<xsl:param name="class" />
<xsl:call-template name="process-p">
<xsl:with-param name="class">title</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="process-schema-title" >
<xsl:param name="class" />
<xsl:call-template name="process-title">
<xsl:with-param name="class">schema-title</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="process-value-of">
<xsl:param name="select"/>
<!-- We generate too much whitespace rather than risking concatenation -->
<axsl:text> </axsl:text>
<axsl:value-of select="{$select}"/>
<axsl:text> </axsl:text>
</xsl:template>
<!-- default output action: the simplest customization is to just override this -->
<xsl:template name="process-message">
<xsl:param name="pattern" />
<xsl:param name="role" />
<xsl:apply-templates mode="text"/>
<xsl:if test=" $message-newline = 'true'" >
<axsl:value-of select="string('&#10;')"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,823 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:src="http://purl.oclc.org/dsdl/9573-11amd1/ns/structure/1.0"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="stdex_front.xsl" />
<xsl:import href="stdex_toc.xsl" />
<xsl:import href="stdex_back.xsl" />
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0//EN" encoding="UTF-8" />
<!-- XSLT stylesheet for ISO/IEC stdex.rnc -->
<!-- version.0.51 -->
<xsl:template match="/">
<!-- contents: { document } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="/src:document">
<!-- contents: { head, body } -->
<html>
<head>
<title>ISO/IEC IT --- Ver.0.50 ---</title>
</head>
<link rel="stylesheet" href="stdex.css" type="text/css" />
<body>
<xsl:call-template name="frontm" />
<hr />
<xsl:call-template name="toc" />
<hr />
<xsl:apply-templates />
<xsl:call-template name="backm" />
</body>
</html>
</xsl:template>
<xsl:template match="src:head">
<!-- contents: { organization & ... } -->
</xsl:template>
<xsl:template match="src:foreword">
<!-- contents: { block*, part-list? } -->
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Foreword</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Avant-propos</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">foreword</xsl:with-param>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</h1>
<xsl:apply-templates />
<hr />
</xsl:template>
<xsl:template match="src:part-list">
<!-- contents: { part+ } -->
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="src:part">
<!-- contents: { number, title } -->
<li>
<span class="italic">
<xsl:text>-&#160;Part&#160;</xsl:text>
<xsl:apply-templates select="src:number"/>
<xsl:text>:&#160;</xsl:text>
<xsl:apply-templates select="src:title"/>
</span>
</li>
</xsl:template>
<xsl:template match="src:part/src:number">
<!-- contents: { positive-integer } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:part/src:title">
<!-- contents: { text } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:introduction">
<!-- contents: { block } -->
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">introduction</xsl:with-param>
<xsl:with-param name="text">Introduction</xsl:with-param>
</xsl:call-template>
</h1>
<xsl:apply-templates />
<hr />
</xsl:template>
<xsl:template name="anchor-text">
<xsl:param name="anc" />
<xsl:param name="text" />
<span id="{$anc}">
<xsl:value-of select="$text" />
</span>
</xsl:template>
<xsl:template match="src:warning">
<!-- contents: { attlist.warning, p* } -->
<xsl:text>WARNING-</xsl:text>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:scope">
<!-- contents: { block } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" />
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Scope</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Domaine d'application</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', $text)" />
</xsl:call-template>
</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:conf">
<!-- contents: { titled-clause } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:normative-references">
<!-- contents: { block*, referenced-document+ } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" />
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Normative references</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>R&#233;f&#233;rences normatives</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', $text)" />
</xsl:call-template>
</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:referenced-document">
<!-- contents: { id, abbrev, title, field*, url } -->
<dl>
<dd>
<xsl:apply-templates />
</dd>
</dl>
</xsl:template>
<xsl:template match="src:abbrev">
<xsl:apply-templates />
<xsl:text>, </xsl:text>
</xsl:template>
<xsl:template match="src:referenced-document/src:title">
<span class="italic">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="src:terms-and-definitions">
<!-- contents: { terms-and-definitions-content } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" />
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Terms and definitions</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Termes, d&#233;finitions et symboles</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', $text)" />
</xsl:call-template>
</h1>
<dl>
<xsl:apply-templates />
</dl>
</xsl:template>
<xsl:template match="src:term-and-definition">
<!-- contents: { term, term*, definition, (example, note, warning)* } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:term-and-definition/src:term">
<!-- contents: { text } -->
<dt>
<xsl:apply-templates />
</dt>
</xsl:template>
<xsl:template match="src:term-and-definition/src:definition">
<!-- contents: { inline } -->
<dd>
<xsl:apply-templates />
</dd>
</xsl:template>
<xsl:template match="src:clause">
<!-- contents: { id, title, clause-content } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:clause/src:title">
<!-- contents: { text | code } -->
<xsl:variable name="level" select="count(ancestor::src:clause|ancestor::src:annex)" />
<xsl:variable name="nth">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:annex//src:clause" format="A.1" />
</xsl:when>
<xsl:otherwise>
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" format="1.1" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="h{$level}">
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="concat($nth, ' ', .)" />
</xsl:call-template>
</xsl:element>
</xsl:template>
<xsl:template match="src:annex">
<!-- contents: { id, @normative, title, clause-content } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:annex/src:title">
<!-- contents: { text | code } -->
<xsl:variable name="nth">
<xsl:number level="multiple" count="src:annex" format="A" />
</xsl:variable>
<h1 class="annex">
<xsl:text>Annex </xsl:text>
<xsl:value-of select="$nth" />
<br />
<xsl:choose>
<xsl:when test="../@normative = 'true'">
<xsl:text>(normative)</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>(informative)</xsl:text>
</xsl:otherwise>
</xsl:choose>
<br />
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc" select="$nth" />
<xsl:with-param name="text" select="." />
</xsl:call-template>
</h1>
</xsl:template>
<xsl:template match="src:bibliography">
<!-- contents: { referenced-document+ } -->
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Bibliography</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Bibliographie</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">bibliography</xsl:with-param>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</h1>
<ol>
<xsl:apply-templates />
</ol>
</xsl:template>
<xsl:template match="src:bibliography/src:referenced-document">
<li>
<xsl:number format="[1] " />
<xsl:apply-templates />
</li>
</xsl:template>
<xsl:template match="src:index">
<!-- contents: { attlist.index, text } -->
<h1>
<xsl:call-template name="anchor-text">
<xsl:with-param name="anc">index</xsl:with-param>
<xsl:with-param name="text">Index</xsl:with-param>
</xsl:call-template>
</h1>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:p">
<!-- contents: { inline } -->
<p>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="src:li/src:p[not(preceding-sibling::*)]">
<!-- contents: { inline } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:ol">
<!-- contents: { li } -->
<ul style="list-style-type: none;">
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="src:ol/src:li">
<!-- contents: { id, block+ } -->
<xsl:variable name="level" select="count(ancestor::src:ol) mod 3" />
<xsl:variable name="format">
<xsl:choose>
<xsl:when test="$level=1">
<xsl:text>a) </xsl:text>
</xsl:when>
<xsl:when test="$level=2">
<xsl:text>1) </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>i) </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<li>
<xsl:number format="{$format}" />
<xsl:apply-templates />
</li>
</xsl:template>
<xsl:template match="src:ul">
<!-- contents: { li } -->
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>
<xsl:template match="src:ul/src:li">
<!-- contents: { block+ } -->
<xsl:variable name="level" select="count(ancestor::src:ul)" />
<xsl:choose>
<xsl:when test="$level=2">
<li>&#183; <xsl:apply-templates /></li>
</xsl:when>
<xsl:otherwise>
<li>- <xsl:apply-templates /></li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:notation-list">
<!-- contents: { notation-item+ } -->
<dl compact="1">
<xsl:apply-templates />
</dl>
</xsl:template>
<xsl:template match="src:notation-item">
<!-- contents: { notation, notation-definition } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:notation">
<!-- contents: { inline } -->
<dt>
<xsl:apply-templates />
</dt>
</xsl:template>
<xsl:template match="src:notation-definition">
<!-- contents: { p, (p | note)* } -->
<dd>
<xsl:apply-templates />
</dd>
</xsl:template>
<xsl:template match="src:example">
<!-- contents: { p+ } -->
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>EXAMPLE</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>EXEMPLE</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<p>
<xsl:value-of select="$text" />
<xsl:text> </xsl:text>
<xsl:if test="count(../src:xmp) &gt; 1">
<xsl:number level="single" count="src:xmp" format="1 " />
</xsl:if>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="src:note">
<!-- contents: { p+ } -->
<p class="note">
<xsl:text>NOTE&#160;&#160;</xsl:text>
<xsl:if test="count(../src:note) &gt; 1">
<xsl:number level="single" count="src:note" format="1 " />
</xsl:if>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="src:code">
<!-- contents: { text } -->
<code>
<xsl:apply-templates />
</code>
</xsl:template>
<xsl:template match="src:b">
<!-- contents: { text } -->
<b>
<xsl:apply-templates />
</b>
</xsl:template>
<xsl:template match="src:i">
<!-- contents: { text } -->
<span class="italic">
<xsl:apply-templates />
</span>
</xsl:template>
<xsl:template match="src:u">
<!-- contents: { text } -->
<u>
<xsl:apply-templates />
</u>
</xsl:template>
<xsl:template match="src:sup">
<!-- contents: { text } -->
<sup>
<xsl:apply-templates />
</sup>
</xsl:template>
<xsl:template match="src:sub">
<!-- contents: { text } -->
<sub>
<xsl:apply-templates />
</sub>
</xsl:template>
<xsl:template match="src:var">
<!-- contents: { text } -->
<var>
<xsl:apply-templates />
</var>
</xsl:template>
<xsl:template match="src:This | src:this">
<!-- contents: { empty } -->
<!-- F: la pr&#233;sente Norme internationale -->
<xsl:choose>
<xsl:when test="/src:document/src:head/src:part-number">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:value-of select="local-name()"/>
<xsl:text> part of </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:value-of select="/src:document/src:head/src:organization"/>
<xsl:text> </xsl:text>
<xsl:value-of select="/src:document/src:head/src:document-number"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:value-of select="local-name()"/>
<xsl:value-of select="/src:document/src:head/src:document-type"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="local-name()='This'">
<xsl:text>La</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>la</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> pr&#233;sente </xsl:text>
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-type='International Standard'">
<xsl:text>Norme internationale</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:Xref | src:xref">
<xsl:variable name="to" select="@to" />
<xsl:for-each select="//src:*[@id=$to]">
<xsl:call-template name="xref-one" />
</xsl:for-each>
</xsl:template>
<xsl:template name="xref-one">
<xsl:choose>
<xsl:when test="self::src:figure">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:figure" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:figure" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="self::src:table">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:table" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:table" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="self::src:li">
<xsl:variable name="level" select="count(ancestor::src:ol) mod 3" />
<xsl:variable name="format">
<xsl:choose>
<xsl:when test="$level=1">
<xsl:text>a) </xsl:text>
</xsl:when>
<xsl:when test="$level=2">
<xsl:text>1) </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>i) </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:number format="{$format}" />
</xsl:when>
<xsl:when test="ancestor::src:clause">
<xsl:number level="multiple" count="src:scope|src:conf|src:normative-references|src:terms-and-definitions|src:clause" format="1.1 " />
</xsl:when>
<xsl:when test="self::src:referenced-document">
<xsl:value-of select="src:abbrev" />
</xsl:when>
<xsl:otherwise>
<xsl:number level="multiple" count="src:annex" format="A.1 " />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:firstterm">
<!-- contents: { text } -->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:strong">
<!-- contents: { text } -->
<strong>
<xsl:apply-templates />
</strong>
</xsl:template>
<xsl:template match="src:artwork">
<!-- contents: { attlist.artwork } -->
<img src="{@entity}.jpg" />
</xsl:template>
<xsl:template match="src:footnote">
<!-- contents: { id, (text | p)+ } -->
<xsl:element name="a">
<xsl:attribute name="onClick">
<xsl:text>alert('</xsl:text>
<xsl:call-template name="fn-mark" />
<xsl:apply-templates />
<xsl:text>')</xsl:text>
</xsl:attribute>
<sup>
<xsl:call-template name="fn-mark" />
</sup>
</xsl:element>
</xsl:template>
<xsl:template name="fn-mark">
<xsl:choose>
<xsl:when test="ancestor::src:figure">
<xsl:number level="single" count="src:fn" format="a) " />
</xsl:when>
<xsl:when test="ancestor::src:table">
<xsl:number level="single" count="src:fn" format="a) " />
</xsl:when>
<xsl:otherwise>
<xsl:number value="count(preceding::src:fn)-count(preceding::src:fn[ancestor::src:figure or
ancestor::src:table])+1" format="1) " />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="src:table">
<!-- contents: { @pgwide, title?, block+ } -->
<div align="center">
<xsl:apply-templates />
<br />
</div>
</xsl:template>
<xsl:template match="src:table/src:title">
<xsl:variable name="ref">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:table" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:table" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="/src:document/src:head/src:document-language='E'">
<xsl:text>Table</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Tableau</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- caption -->
<b>
<span id="tab{$ref}">
<xsl:value-of select="concat($text, ' ', $ref)" /> &#8211; <xsl:value-of select="." />
</span>
</b>
<!-- /caption -->
</xsl:template>
<xsl:template match="src:figure">
<!-- contents: { @pgwide, title?, block+ } -->
<div align="center">
<xsl:apply-templates select="*[not(self::src:title)]"/>
<xsl:apply-templates select="src:title"/>
</div>
</xsl:template>
<xsl:template match="src:figure/src:title">
<xsl:variable name="ref">
<xsl:choose>
<xsl:when test="ancestor::src:annex">
<xsl:number level="multiple" count="src:annex|src:figure" format="A.1 " />
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" count="src:figure" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div align="center">
<b>
<span id="fig{$ref}">
<xsl:text>Figure </xsl:text>
<xsl:value-of select="$ref" /> &#8211; <xsl:value-of select="." />
</span>
</b>
</div>
</xsl:template>
<xsl:template match="src:tabular">
<table>
<xsl:choose>
<xsl:when test="@frame=&quot;none&quot;" />
<xsl:otherwise>
<xsl:attribute name="border" />
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="src:tgroup">
<xsl:apply-templates select="src:colspec" />
<xsl:apply-templates select="src:thead" />
<xsl:apply-templates select="src:tbody" />
<xsl:apply-templates select="src:tfoot" />
<tr>
<td colspan="100">
<xsl:apply-templates select=".//src:note" />
</td>
</tr>
</xsl:template>
<xsl:template match="src:colspec" />
<xsl:template match="src:thead">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:tbody">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:tfoot">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="src:row">
<tr>
<xsl:choose>
<xsl:when test="parent::src:thead or parent::src:tfoot">
<xsl:attribute name="bgcolor">#d0d0d0</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="@valign">
<xsl:attribute name="valign">
<xsl:value-of select="@valign" />
</xsl:attribute>
</xsl:when>
<xsl:when test="parent::src:*[@valign]">
<xsl:attribute name="valign">
<xsl:value-of select="parent::src:*[@valign]/@valign" />
</xsl:attribute>
</xsl:when>
<xsl:when test="parent::src:thead">
<xsl:attribute name="valign">bottom</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="valign">top</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@align">
<xsl:attribute name="align">
<xsl:value-of select="@align" />
</xsl:attribute>
</xsl:when>
<xsl:when test="ancestor::src:*[@align]">
<xsl:attribute name="align">
<xsl:value-of select="ancestor::src:*[@align]/@align" />
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:apply-templates />
</tr>
</xsl:template>
<xsl:template match="src:entry">
<xsl:choose>
<xsl:when test="ancestor::src:thead">
<xsl:call-template name="ent">
<xsl:with-param name="tag">th</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="ent">
<xsl:with-param name="tag">td</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ent">
<xsl:param name="tag" />
<xsl:element name="{$tag}">
<xsl:if test="@valign">
<xsl:attribute name="valign">
<xsl:value-of select="@valign" />
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="@align">
<xsl:attribute name="align">
<xsl:value-of select="@align" />
</xsl:attribute>
</xsl:when>
<xsl:when test="ancestor::src:*[@align]">
<xsl:attribute name="align">
<xsl:value-of select="ancestor::src:*[@align]/@align" />
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:if test="@morerows">
<xsl:attribute name="rowspan">
<xsl:value-of select="@morerows + 1" />
</xsl:attribute>
</xsl:if>
<xsl:if test="@namest and @nameend">
<xsl:call-template name="colspan">
<xsl:with-param name="namest" select="@namest" />
<xsl:with-param name="nameend" select="@nameend" />
</xsl:call-template>
</xsl:if>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template name="colspan">
<xsl:param name="namest" />
<xsl:param name="nameend" />
<xsl:call-template name="colspan-sub">
<xsl:with-param name="numst">
<xsl:choose>
<xsl:when test="parent::src:row/preceding-sibling::src:colspec[@colname=$namest]">
<xsl:value-of
select="count(parent::src:row/preceding-sibling::src:colspec[@colname=$namest]/preceding-sibling::src:colspec)"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="count(ancestor::src:tgroup/child::src:colspec[@colname=$namest]/preceding-sibling::src:colspec)"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="numend">
<xsl:choose>
<xsl:when test="parent::src:row/preceding-sibling::src:colspec[@colname=$nameend]">
<xsl:value-of
select="count(parent::src:row/preceding-sibling::src:colspec[@colname=$nameend]/preceding-sibling::src:colspec)"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="count(ancestor::src:tgroup/child::src:colspec[@colname=$nameend]/preceding-sibling::src:colspec)"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="colspan-sub">
<xsl:param name="numst" />
<xsl:param name="numend" />
<xsl:attribute name="colspan">
<xsl:value-of select="$numend - $numst + 1" />
</xsl:attribute>
</xsl:template>
<xsl:template match="text()">
<xsl:if test="normalize-space(.)!=' '">
<xsl:value-of select="." />
</xsl:if>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load Diff