schematron-wrapper 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.rspec +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +6 -0
- data/LICENSE +354 -0
- data/README.md +37 -0
- data/Rakefile +10 -0
- data/bin/saxon9he.jar +0 -0
- data/iso-schematron-xslt2/ExtractSchFromRNG-2.xsl +75 -0
- data/iso-schematron-xslt2/ExtractSchFromXSD-2.xsl +77 -0
- data/iso-schematron-xslt2/iso_abstract_expand.xsl +297 -0
- data/iso-schematron-xslt2/iso_dsdl_include.xsl +1508 -0
- data/iso-schematron-xslt2/iso_schematron_message_xslt2.xsl +55 -0
- data/iso-schematron-xslt2/iso_schematron_skeleton_for_saxon.xsl +2299 -0
- data/iso-schematron-xslt2/iso_svrl_for_xslt2.xsl +684 -0
- data/iso-schematron-xslt2/readme.txt +100 -0
- data/iso-schematron-xslt2/sch-messages-cs.xhtml +56 -0
- data/iso-schematron-xslt2/sch-messages-de.xhtml +57 -0
- data/iso-schematron-xslt2/sch-messages-en.xhtml +57 -0
- data/iso-schematron-xslt2/sch-messages-fr.xhtml +54 -0
- data/iso-schematron-xslt2/sch-messages-nl.xhtml +58 -0
- data/iso-schematron-xslt2/schematron-skeleton-api.htm +723 -0
- data/lib/schematron.rb +6 -0
- data/lib/schematron/utils.rb +29 -0
- data/lib/schematron/version.rb +4 -0
- data/lib/schematron/xslt2.rb +71 -0
- data/schematron_wrapper.gemspec +25 -0
- data/spec/lib/schematron/xslt2_spec.rb +50 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/samples/compiled.xsl +334 -0
- data/spec/support/samples/initial.sch +52 -0
- data/spec/support/samples/target.xml +1032 -0
- data/spec/support/samples/validation_result.xml +46 -0
- metadata +99 -0
data/bin/saxon9he.jar
ADDED
Binary file
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!--
|
3
|
+
Stylesheet for extracting Schematron information from a RELAX-NG schema.
|
4
|
+
Based on the stylesheet for extracting Schematron information from W3C XML Schema.
|
5
|
+
Created by Eddie Robertsson 2002/06/01
|
6
|
+
Update for ISO Schematron using XSLT2 Rick Jelliffe 2010/04/14
|
7
|
+
-->
|
8
|
+
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
9
|
+
xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns:rng="http://relaxng.org/ns/structure/1.0">
|
10
|
+
<!-- Set the output to be XML with an XML declaration and use indentation -->
|
11
|
+
<xsl:output method="xml" omit-xml-declaration="no" indent="yes" standalone="yes"/>
|
12
|
+
<!-- -->
|
13
|
+
<!-- match schema and call recursive template to extract included schemas -->
|
14
|
+
<!-- -->
|
15
|
+
<xsl:template match="/rng:grammar | /rng:element">
|
16
|
+
<!-- call the schema definition template ... -->
|
17
|
+
<xsl:call-template name="gatherSchema">
|
18
|
+
<!-- ... with current node as the $schemas parameter ... -->
|
19
|
+
<xsl:with-param name="schemas" select="."/>
|
20
|
+
<!-- ... and any includes in the $include parameter -->
|
21
|
+
<xsl:with-param name="includes" select="document(/rng:grammar/rng:include/@href
|
22
|
+
| //rng:externalRef/@href)"/>
|
23
|
+
</xsl:call-template>
|
24
|
+
</xsl:template>
|
25
|
+
<!-- -->
|
26
|
+
<!-- gather all included schemas into a single parameter variable -->
|
27
|
+
<!-- -->
|
28
|
+
<xsl:template name="gatherSchema">
|
29
|
+
<xsl:param name="schemas"/>
|
30
|
+
<xsl:param name="includes"/>
|
31
|
+
<xsl:choose>
|
32
|
+
<xsl:when test="count($schemas) < count($schemas | $includes)">
|
33
|
+
<!-- when $includes includes something new, recurse ... -->
|
34
|
+
<xsl:call-template name="gatherSchema">
|
35
|
+
<!-- ... with current $includes added to the $schemas parameter ... -->
|
36
|
+
<xsl:with-param name="schemas" select="$schemas | $includes"/>
|
37
|
+
<!-- ... and any *new* includes in the $include parameter -->
|
38
|
+
<xsl:with-param name="includes" select="document($includes/rng:grammar/rng:include/@href
|
39
|
+
| $includes//rng:externalRef/@href)"/>
|
40
|
+
</xsl:call-template>
|
41
|
+
</xsl:when>
|
42
|
+
<xsl:otherwise>
|
43
|
+
<!-- we have the complete set of included schemas, so now let's output the embedded schematron -->
|
44
|
+
<xsl:call-template name="output">
|
45
|
+
<xsl:with-param name="schemas" select="$schemas"/>
|
46
|
+
</xsl:call-template>
|
47
|
+
</xsl:otherwise>
|
48
|
+
</xsl:choose>
|
49
|
+
</xsl:template>
|
50
|
+
<!-- -->
|
51
|
+
<!-- output the schematron information -->
|
52
|
+
<!-- -->
|
53
|
+
<xsl:template name="output">
|
54
|
+
<xsl:param name="schemas"/>
|
55
|
+
<!-- -->
|
56
|
+
<sch:schema queryBinding="xslt2" >
|
57
|
+
<!-- get header-type elements - eg title and especially ns -->
|
58
|
+
<!-- title (just one) -->
|
59
|
+
<xsl:copy-of select="$schemas//sch:title[1]"/>
|
60
|
+
<!-- get remaining schematron schema children -->
|
61
|
+
<!-- get non-blank namespace elements, dropping duplicates -->
|
62
|
+
<xsl:for-each select="$schemas//sch:ns">
|
63
|
+
<xsl:if test="generate-id(.) = generate-id($schemas//sch:ns[@prefix = current()/@prefix][1])">
|
64
|
+
<xsl:copy-of select="."/>
|
65
|
+
</xsl:if>
|
66
|
+
</xsl:for-each>
|
67
|
+
<xsl:copy-of select="$schemas//sch:phase"/>
|
68
|
+
<xsl:copy-of select="$schemas//sch:pattern"/>
|
69
|
+
<sch:diagnostics>
|
70
|
+
<xsl:copy-of select="$schemas//sch:diagnostics/*"/>
|
71
|
+
</sch:diagnostics>
|
72
|
+
</sch:schema>
|
73
|
+
</xsl:template>
|
74
|
+
<!-- -->
|
75
|
+
</xsl:transform>
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!--
|
3
|
+
based on an original transform by Eddie Robertsson
|
4
|
+
2001/04/21 fn: added support for included schemas
|
5
|
+
2001/06/27 er: changed XMl Schema prefix from xsd: to xs: and changed to the Rec namespace
|
6
|
+
2010/04/14 rj: Update for ISO Schematron using xslt2
|
7
|
+
-->
|
8
|
+
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
9
|
+
xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
10
|
+
<!-- Set the output to be XML with an XML declaration and use indentation -->
|
11
|
+
<xsl:output method="xml" omit-xml-declaration="no" indent="yes" standalone="yes"/>
|
12
|
+
<!-- -->
|
13
|
+
<!-- match schema and call recursive template to extract included schemas -->
|
14
|
+
<!-- -->
|
15
|
+
<xsl:template match="xs:schema">
|
16
|
+
<!-- call the schema definition template ... -->
|
17
|
+
<xsl:call-template name="gatherSchema">
|
18
|
+
<!-- ... with current current root as the $schemas parameter ... -->
|
19
|
+
<xsl:with-param name="schemas" select="/"/>
|
20
|
+
<!-- ... and any includes in the $include parameter -->
|
21
|
+
<xsl:with-param name="includes"
|
22
|
+
select="document(/xs:schema/xs:*[self::xs:include or self::xs:import or self::xs:redefine]/@schemaLocation)"/>
|
23
|
+
</xsl:call-template>
|
24
|
+
</xsl:template>
|
25
|
+
<!-- -->
|
26
|
+
<!-- gather all included schemas into a single parameter variable -->
|
27
|
+
<!-- -->
|
28
|
+
<xsl:template name="gatherSchema">
|
29
|
+
<xsl:param name="schemas"/>
|
30
|
+
<xsl:param name="includes"/>
|
31
|
+
<xsl:choose>
|
32
|
+
<xsl:when test="count($schemas) < count($schemas | $includes)">
|
33
|
+
<!-- when $includes includes something new, recurse ... -->
|
34
|
+
<xsl:call-template name="gatherSchema">
|
35
|
+
<!-- ... with current $includes added to the $schemas parameter ... -->
|
36
|
+
<xsl:with-param name="schemas" select="$schemas | $includes"/>
|
37
|
+
<!-- ... and any *new* includes in the $include parameter -->
|
38
|
+
<xsl:with-param name="includes"
|
39
|
+
select="document($includes/xs:schema/xs:*[self::xs:include or self::xs:import or self::xs:redefine]/@schemaLocation)"/>
|
40
|
+
</xsl:call-template>
|
41
|
+
</xsl:when>
|
42
|
+
<xsl:otherwise>
|
43
|
+
<!-- we have the complete set of included schemas,
|
44
|
+
so now let's output the embedded schematron -->
|
45
|
+
<xsl:call-template name="output">
|
46
|
+
<xsl:with-param name="schemas" select="$schemas"/>
|
47
|
+
</xsl:call-template>
|
48
|
+
</xsl:otherwise>
|
49
|
+
</xsl:choose>
|
50
|
+
</xsl:template>
|
51
|
+
<!-- -->
|
52
|
+
<!-- output the schematron information -->
|
53
|
+
<!-- -->
|
54
|
+
<xsl:template name="output">
|
55
|
+
<xsl:param name="schemas"/>
|
56
|
+
<!-- -->
|
57
|
+
<sch:schema queryBinding="xslt2">
|
58
|
+
<!-- get header-type elements - eg title and especially ns -->
|
59
|
+
<!-- title (just one) -->
|
60
|
+
<xsl:copy-of select="$schemas//xs:appinfo/sch:title[1]"/>
|
61
|
+
<!-- get remaining schematron schema children -->
|
62
|
+
<!-- get non-blank namespace elements, dropping duplicates -->
|
63
|
+
<xsl:for-each select="$schemas//xs:appinfo/sch:ns">
|
64
|
+
<xsl:if test="generate-id(.) =
|
65
|
+
generate-id($schemas//xs:appinfo/sch:ns[@prefix = current()/@prefix][1])">
|
66
|
+
<xsl:copy-of select="."/>
|
67
|
+
</xsl:if>
|
68
|
+
</xsl:for-each>
|
69
|
+
<xsl:copy-of select="$schemas//xs:appinfo/sch:phase"/>
|
70
|
+
<xsl:copy-of select="$schemas//xs:appinfo/sch:pattern"/>
|
71
|
+
<sch:diagnostics>
|
72
|
+
<xsl:copy-of select="$schemas//xs:appinfo/sch:diagnostics/*"/>
|
73
|
+
</sch:diagnostics>
|
74
|
+
</sch:schema>
|
75
|
+
</xsl:template>
|
76
|
+
<!-- -->
|
77
|
+
</xsl:transform>
|
@@ -0,0 +1,297 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><?xar XSLT?>
|
2
|
+
|
3
|
+
<!--
|
4
|
+
OVERVIEW - iso_abstract_expand.xsl
|
5
|
+
|
6
|
+
This is a preprocessor for ISO Schematron, which implements abstract patterns.
|
7
|
+
It also
|
8
|
+
* extracts a particular schema using an ID, where there are multiple
|
9
|
+
schemas, such as when they are embedded in the same NVDL script
|
10
|
+
* experimentally, allows parameter recognition and substitution inside
|
11
|
+
text as well as @context, @test, & @select.
|
12
|
+
|
13
|
+
|
14
|
+
This should be used after iso-dsdl-include.xsl and before the skeleton or
|
15
|
+
meta-stylesheet (e.g. iso-svrl.xsl) . It only requires XSLT 1.
|
16
|
+
|
17
|
+
Each kind of inclusion can be turned off (or on) on the command line.
|
18
|
+
|
19
|
+
-->
|
20
|
+
<!--
|
21
|
+
VERSION INFORMATION
|
22
|
+
2008-09-18 RJ
|
23
|
+
* move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
|
24
|
+
|
25
|
+
2008-07-29 RJ
|
26
|
+
* Create. Pull out as distinct XSL in its own namespace from old iso_pre_pro.xsl
|
27
|
+
* Put everything in private namespace
|
28
|
+
* Rewrite replace_substring named template so that copyright is clear
|
29
|
+
|
30
|
+
2008-07-24 RJ
|
31
|
+
* correct abstract patterns so for correct names: param/@name and
|
32
|
+
param/@value
|
33
|
+
|
34
|
+
2007-01-12 RJ
|
35
|
+
* Use ISO namespace
|
36
|
+
* Use pattern/@id not pattern/@name
|
37
|
+
* Add Oliver Becker's suggests from old Schematron-love-in list for <copy>
|
38
|
+
* Add XT -ism?
|
39
|
+
2003 RJ
|
40
|
+
* Original written for old namespace
|
41
|
+
* http://www.topologi.com/resources/iso-pre-pro.xsl
|
42
|
+
-->
|
43
|
+
<!--
|
44
|
+
LEGAL INFORMATION
|
45
|
+
|
46
|
+
Copyright (c) 2000-2008 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
|
47
|
+
|
48
|
+
This software is provided 'as-is', without any express or implied warranty.
|
49
|
+
In no event will the authors be held liable for any damages arising from
|
50
|
+
the use of this software.
|
51
|
+
|
52
|
+
Permission is granted to anyone to use this software for any purpose,
|
53
|
+
including commercial applications, and to alter it and redistribute it freely,
|
54
|
+
subject to the following restrictions:
|
55
|
+
|
56
|
+
1. The origin of this software must not be misrepresented; you must not claim
|
57
|
+
that you wrote the original software. If you use this software in a product,
|
58
|
+
an acknowledgment in the product documentation would be appreciated but is
|
59
|
+
not required.
|
60
|
+
|
61
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
62
|
+
misrepresented as being the original software.
|
63
|
+
|
64
|
+
3. This notice may not be removed or altered from any source distribution.
|
65
|
+
-->
|
66
|
+
<xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
|
67
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
68
|
+
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
|
69
|
+
xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
|
70
|
+
|
71
|
+
xmlns:iae="http://www.schematron.com/namespace/iae"
|
72
|
+
|
73
|
+
>
|
74
|
+
|
75
|
+
<xslt:param name="schema-id"></xslt:param>
|
76
|
+
|
77
|
+
|
78
|
+
<!-- Driver for the mode -->
|
79
|
+
<xsl:template match="/">
|
80
|
+
<xsl:apply-templates select="." mode="iae:go" />
|
81
|
+
</xsl:template>
|
82
|
+
|
83
|
+
|
84
|
+
<!-- ================================================================================== -->
|
85
|
+
<!-- Normal processing rules -->
|
86
|
+
<!-- ================================================================================== -->
|
87
|
+
<!-- Output only the selected schema -->
|
88
|
+
<xslt:template match="iso:schema" >
|
89
|
+
<xsl:if test="string-length($schema-id) =0 or @id= $schema-id ">
|
90
|
+
<xslt:copy>
|
91
|
+
<xslt:copy-of select="@*" />
|
92
|
+
<xslt:apply-templates mode="iae:go" />
|
93
|
+
</xslt:copy>
|
94
|
+
</xsl:if>
|
95
|
+
</xslt:template>
|
96
|
+
|
97
|
+
|
98
|
+
<!-- Strip out any foreign elements above the Schematron schema .
|
99
|
+
-->
|
100
|
+
<xslt:template match="*[not(ancestor-or-self::iso:*)]" mode="iae:go" >
|
101
|
+
<xslt:apply-templates mode="iae:go" />
|
102
|
+
</xslt:template>
|
103
|
+
|
104
|
+
|
105
|
+
<!-- ================================================================================== -->
|
106
|
+
<!-- Handle Schematron abstract pattern preprocessing -->
|
107
|
+
<!-- abstract-to-real calls
|
108
|
+
do-pattern calls
|
109
|
+
macro-expand calls
|
110
|
+
multi-macro-expand
|
111
|
+
replace-substring -->
|
112
|
+
<!-- ================================================================================== -->
|
113
|
+
|
114
|
+
<!--
|
115
|
+
Abstract patterns allow you to say, for example
|
116
|
+
|
117
|
+
<pattern name="htmlTable" is-a="table">
|
118
|
+
<param name="row" value="html:tr"/>
|
119
|
+
<param name="cell" value="html:td" />
|
120
|
+
<param name="table" value="html:table" />
|
121
|
+
</pattern>
|
122
|
+
|
123
|
+
For a good introduction, see Uche Ogbujii's article for IBM DeveloperWorks
|
124
|
+
"Discover the flexibility of Schematron abstract patterns"
|
125
|
+
http://www-128.ibm.com/developerworks/xml/library/x-stron.html
|
126
|
+
However, note that ISO Schematron uses @name and @value attributes on
|
127
|
+
the iso:param element, and @id not @name on the pattern element.
|
128
|
+
|
129
|
+
-->
|
130
|
+
|
131
|
+
<!-- Suppress declarations of abstract patterns -->
|
132
|
+
<xslt:template match="iso:pattern[@abstract='true']" mode="iae:go" >
|
133
|
+
<xslt:comment>Suppressed abstract pattern <xslt:value-of select="@id"/> was here</xslt:comment>
|
134
|
+
</xslt:template>
|
135
|
+
|
136
|
+
|
137
|
+
<!-- Suppress uses of abstract patterns -->
|
138
|
+
<xslt:template match="iso:pattern[@is-a]" mode="iae:go" >
|
139
|
+
|
140
|
+
<xslt:comment>Start pattern based on abstract <xslt:value-of select="@is-a"/></xslt:comment>
|
141
|
+
|
142
|
+
<xslt:call-template name="iae:abstract-to-real" >
|
143
|
+
<xslt:with-param name="caller" select="@id" />
|
144
|
+
<xslt:with-param name="is-a" select="@is-a" />
|
145
|
+
</xslt:call-template>
|
146
|
+
|
147
|
+
</xslt:template>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<!-- output everything else unchanged -->
|
152
|
+
<xslt:template match="*" priority="-1" mode="iae:go" >
|
153
|
+
<xslt:copy>
|
154
|
+
<xslt:copy-of select="@*" />
|
155
|
+
<xslt:apply-templates mode="iae:go"/>
|
156
|
+
</xslt:copy>
|
157
|
+
</xslt:template>
|
158
|
+
|
159
|
+
<!-- Templates for macro expansion of abstract patterns -->
|
160
|
+
<!-- Sets up the initial conditions for the recursive call -->
|
161
|
+
<xslt:template name="iae:macro-expand">
|
162
|
+
<xslt:param name="caller"/>
|
163
|
+
<xslt:param name="text" />
|
164
|
+
<xslt:call-template name="iae:multi-macro-expand">
|
165
|
+
<xslt:with-param name="caller" select="$caller"/>
|
166
|
+
<xslt:with-param name="text" select="$text"/>
|
167
|
+
<xslt:with-param name="paramNumber" select="1"/>
|
168
|
+
</xslt:call-template>
|
169
|
+
|
170
|
+
</xslt:template>
|
171
|
+
|
172
|
+
<!-- Template to replace the current parameter and then
|
173
|
+
recurse to replace subsequent parameters. -->
|
174
|
+
|
175
|
+
<xslt:template name="iae:multi-macro-expand">
|
176
|
+
<xslt:param name="caller"/>
|
177
|
+
<xslt:param name="text" />
|
178
|
+
<xslt:param name="paramNumber" />
|
179
|
+
|
180
|
+
|
181
|
+
<xslt:choose>
|
182
|
+
<xslt:when test="//iso:pattern[@id=$caller]/iso:param[ $paramNumber]">
|
183
|
+
|
184
|
+
<xslt:call-template name="iae:multi-macro-expand">
|
185
|
+
<xslt:with-param name="caller" select="$caller"/>
|
186
|
+
<xslt:with-param name="paramNumber" select="$paramNumber + 1"/>
|
187
|
+
<xslt:with-param name="text" >
|
188
|
+
<xslt:call-template name="iae:replace-substring">
|
189
|
+
<xslt:with-param name="original" select="$text"/>
|
190
|
+
<xslt:with-param name="substring"
|
191
|
+
select="concat('$', //iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@name)"/>
|
192
|
+
<xslt:with-param name="replacement"
|
193
|
+
select="//iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@value"/>
|
194
|
+
</xslt:call-template>
|
195
|
+
</xslt:with-param>
|
196
|
+
</xslt:call-template>
|
197
|
+
</xslt:when>
|
198
|
+
<xslt:otherwise><xslt:value-of select="$text" /></xslt:otherwise>
|
199
|
+
|
200
|
+
</xslt:choose>
|
201
|
+
</xslt:template>
|
202
|
+
|
203
|
+
|
204
|
+
<!-- generate the real pattern from an abstract pattern + parameters-->
|
205
|
+
<xslt:template name="iae:abstract-to-real" >
|
206
|
+
<xslt:param name="caller"/>
|
207
|
+
<xslt:param name="is-a" />
|
208
|
+
<xslt:for-each select="//iso:pattern[@id= $is-a]">
|
209
|
+
<xslt:copy>
|
210
|
+
|
211
|
+
<xslt:choose>
|
212
|
+
<xslt:when test=" string-length( $caller ) = 0">
|
213
|
+
<xslt:attribute name="id"><xslt:value-of select="concat( generate-id(.) , $is-a)" /></xslt:attribute>
|
214
|
+
</xslt:when>
|
215
|
+
<xslt:otherwise>
|
216
|
+
<xslt:attribute name="id"><xslt:value-of select="$caller" /></xslt:attribute>
|
217
|
+
</xslt:otherwise>
|
218
|
+
</xslt:choose>
|
219
|
+
|
220
|
+
<xslt:apply-templates select="*|text()" mode="iae:do-pattern" >
|
221
|
+
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
|
222
|
+
</xslt:apply-templates>
|
223
|
+
|
224
|
+
</xslt:copy>
|
225
|
+
</xslt:for-each>
|
226
|
+
</xslt:template>
|
227
|
+
|
228
|
+
|
229
|
+
<!-- Generate a non-abstract pattern -->
|
230
|
+
<xslt:template mode="iae:do-pattern" match="*">
|
231
|
+
<xslt:param name="caller"/>
|
232
|
+
<xslt:copy>
|
233
|
+
<xslt:for-each select="@*[name()='test' or name()='context' or name()='select']">
|
234
|
+
<xslt:attribute name="{name()}">
|
235
|
+
<xslt:call-template name="iae:macro-expand">
|
236
|
+
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
|
237
|
+
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
|
238
|
+
</xslt:call-template>
|
239
|
+
</xslt:attribute>
|
240
|
+
</xslt:for-each>
|
241
|
+
<xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select']" />
|
242
|
+
<xsl:for-each select="node()">
|
243
|
+
<xsl:choose>
|
244
|
+
<!-- Experiment: replace macros in text as well, to allow parameterized assertions
|
245
|
+
and so on, without having to have spurious <iso:value-of> calls and multiple
|
246
|
+
delimiting -->
|
247
|
+
<xsl:when test="self::text()">
|
248
|
+
<xslt:call-template name="iae:macro-expand">
|
249
|
+
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
|
250
|
+
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
|
251
|
+
</xslt:call-template>
|
252
|
+
</xsl:when>
|
253
|
+
<xsl:otherwise>
|
254
|
+
<xslt:apply-templates select="." mode="iae:do-pattern">
|
255
|
+
<xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
|
256
|
+
</xslt:apply-templates>
|
257
|
+
</xsl:otherwise>
|
258
|
+
</xsl:choose>
|
259
|
+
</xsl:for-each>
|
260
|
+
</xslt:copy>
|
261
|
+
</xslt:template>
|
262
|
+
|
263
|
+
<!-- UTILITIES -->
|
264
|
+
<!-- Simple version of replace-substring function -->
|
265
|
+
<xslt:template name="iae:replace-substring">
|
266
|
+
<xslt:param name="original" />
|
267
|
+
<xslt:param name="substring" />
|
268
|
+
<xslt:param name="replacement" select="''"/>
|
269
|
+
|
270
|
+
<xsl:choose>
|
271
|
+
<xsl:when test="not($original)" />
|
272
|
+
<xsl:when test="not(string($substring))">
|
273
|
+
<xsl:value-of select="$original" />
|
274
|
+
</xsl:when>
|
275
|
+
<xsl:when test="contains($original, $substring)">
|
276
|
+
<xsl:variable name="before" select="substring-before($original, $substring)" />
|
277
|
+
<xsl:variable name="after" select="substring-after($original, $substring)" />
|
278
|
+
|
279
|
+
<xsl:value-of select="$before" />
|
280
|
+
<xsl:value-of select="$replacement" />
|
281
|
+
<!-- recursion -->
|
282
|
+
<xsl:call-template name="iae:replace-substring">
|
283
|
+
<xsl:with-param name="original" select="$after" />
|
284
|
+
<xsl:with-param name="substring" select="$substring" />
|
285
|
+
<xsl:with-param name="replacement" select="$replacement" />
|
286
|
+
</xsl:call-template>
|
287
|
+
</xsl:when>
|
288
|
+
<xsl:otherwise>
|
289
|
+
<!-- no substitution -->
|
290
|
+
<xsl:value-of select="$original" />
|
291
|
+
</xsl:otherwise>
|
292
|
+
</xsl:choose>
|
293
|
+
</xslt:template>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
</xslt:stylesheet>
|