lxml 5.2.0__cp310-cp310-win32.whl → 5.2.2__cp310-cp310-win32.whl

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.
Files changed (89) hide show
  1. lxml/ElementInclude.py +244 -244
  2. lxml/__init__.py +22 -22
  3. lxml/_elementpath.cp310-win32.pyd +0 -0
  4. lxml/_elementpath.py +341 -341
  5. lxml/apihelpers.pxi +1793 -1793
  6. lxml/builder.cp310-win32.pyd +0 -0
  7. lxml/builder.py +232 -232
  8. lxml/classlookup.pxi +580 -580
  9. lxml/cleanup.pxi +215 -215
  10. lxml/cssselect.py +101 -101
  11. lxml/debug.pxi +90 -90
  12. lxml/docloader.pxi +178 -178
  13. lxml/doctestcompare.py +488 -488
  14. lxml/dtd.pxi +478 -478
  15. lxml/etree.cp310-win32.pyd +0 -0
  16. lxml/etree.h +6 -6
  17. lxml/etree.pyx +3732 -3711
  18. lxml/extensions.pxi +833 -833
  19. lxml/html/ElementSoup.py +10 -10
  20. lxml/html/__init__.py +1923 -1923
  21. lxml/html/_diffcommand.py +86 -86
  22. lxml/html/_html5builder.py +100 -100
  23. lxml/html/_setmixin.py +56 -56
  24. lxml/html/builder.py +133 -133
  25. lxml/html/clean.py +21 -21
  26. lxml/html/defs.py +135 -135
  27. lxml/html/diff.cp310-win32.pyd +0 -0
  28. lxml/html/diff.py +878 -878
  29. lxml/html/formfill.py +299 -299
  30. lxml/html/html5parser.py +260 -260
  31. lxml/html/soupparser.py +314 -314
  32. lxml/html/usedoctest.py +13 -13
  33. lxml/includes/c14n.pxd +25 -25
  34. lxml/includes/config.pxd +3 -3
  35. lxml/includes/dtdvalid.pxd +18 -18
  36. lxml/includes/etree_defs.h +379 -379
  37. lxml/includes/etreepublic.pxd +237 -237
  38. lxml/includes/htmlparser.pxd +56 -56
  39. lxml/includes/lxml-version.h +1 -1
  40. lxml/includes/relaxng.pxd +64 -64
  41. lxml/includes/schematron.pxd +34 -34
  42. lxml/includes/tree.pxd +494 -494
  43. lxml/includes/uri.pxd +5 -5
  44. lxml/includes/xinclude.pxd +22 -22
  45. lxml/includes/xmlerror.pxd +852 -852
  46. lxml/includes/xmlparser.pxd +265 -265
  47. lxml/includes/xmlschema.pxd +35 -35
  48. lxml/includes/xpath.pxd +136 -136
  49. lxml/includes/xslt.pxd +190 -190
  50. lxml/isoschematron/__init__.py +348 -348
  51. lxml/isoschematron/resources/rng/iso-schematron.rng +709 -709
  52. lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl +75 -75
  53. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl +312 -312
  54. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl +1159 -1159
  55. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl +54 -54
  56. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl +1796 -1796
  57. lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl +588 -588
  58. lxml/iterparse.pxi +438 -438
  59. lxml/lxml.etree.h +6 -6
  60. lxml/nsclasses.pxi +281 -281
  61. lxml/objectify.cp310-win32.pyd +0 -0
  62. lxml/objectify.pyx +2145 -2145
  63. lxml/objectpath.pxi +332 -332
  64. lxml/parser.pxi +1994 -1994
  65. lxml/parsertarget.pxi +180 -180
  66. lxml/proxy.pxi +619 -619
  67. lxml/public-api.pxi +178 -178
  68. lxml/pyclasslookup.py +3 -3
  69. lxml/readonlytree.pxi +565 -565
  70. lxml/relaxng.pxi +165 -165
  71. lxml/sax.cp310-win32.pyd +0 -0
  72. lxml/sax.py +275 -275
  73. lxml/saxparser.pxi +875 -875
  74. lxml/schematron.pxi +168 -168
  75. lxml/serializer.pxi +1871 -1871
  76. lxml/usedoctest.py +13 -13
  77. lxml/xinclude.pxi +67 -67
  78. lxml/xmlerror.pxi +1654 -1654
  79. lxml/xmlid.pxi +179 -179
  80. lxml/xmlschema.pxi +215 -215
  81. lxml/xpath.pxi +487 -487
  82. lxml/xslt.pxi +950 -950
  83. lxml/xsltext.pxi +242 -242
  84. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSE.txt +29 -29
  85. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/LICENSES.txt +29 -29
  86. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/METADATA +9 -17
  87. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/RECORD +89 -89
  88. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/WHEEL +0 -0
  89. {lxml-5.2.0.dist-info → lxml-5.2.2.dist-info}/top_level.txt +0 -0
@@ -1,313 +1,313 @@
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
- * allows parameter substitution inside @context, @test, @select, @path
11
- * experimentally, allows parameter recognition and substitution inside
12
- text (NOTE: to be removed, for compataibility with other implementations,
13
- please do not use this)
14
-
15
- This should be used after iso-dsdl-include.xsl and before the skeleton or
16
- meta-stylesheet (e.g. iso-svrl.xsl) . It only requires XSLT 1.
17
-
18
- Each kind of inclusion can be turned off (or on) on the command line.
19
-
20
- -->
21
-
22
- <!--
23
- Open Source Initiative OSI - The MIT License:Licensing
24
- [OSI Approved License]
25
-
26
- This source code was previously available under the zlib/libpng license.
27
- Attribution is polite.
28
-
29
- The MIT License
30
-
31
- Copyright (c) 2004-2010 Rick Jellife and Academia Sinica Computing Centre, Taiwan
32
-
33
- Permission is hereby granted, free of charge, to any person obtaining a copy
34
- of this software and associated documentation files (the "Software"), to deal
35
- in the Software without restriction, including without limitation the rights
36
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
- copies of the Software, and to permit persons to whom the Software is
38
- furnished to do so, subject to the following conditions:
39
-
40
- The above copyright notice and this permission notice shall be included in
41
- all copies or substantial portions of the Software.
42
-
43
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49
- THE SOFTWARE.
50
- -->
51
-
52
- <!--
53
- VERSION INFORMATION
54
- 2013-09-19 RJ
55
- * Allow macro expansion in @path attributes, eg. for sch:name/@path
56
-
57
- 2010-07-10 RJ
58
- * Move to MIT license
59
-
60
- 2008-09-18 RJ
61
- * move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
62
-
63
- 2008-07-29 RJ
64
- * Create. Pull out as distinct XSL in its own namespace from old iso_pre_pro.xsl
65
- * Put everything in private namespace
66
- * Rewrite replace_substring named template so that copyright is clear
67
-
68
- 2008-07-24 RJ
69
- * correct abstract patterns so for correct names: param/@name and
70
- param/@value
71
-
72
- 2007-01-12 RJ
73
- * Use ISO namespace
74
- * Use pattern/@id not pattern/@name
75
- * Add Oliver Becker's suggests from old Schematron-love-in list for <copy>
76
- * Add XT -ism?
77
- 2003 RJ
78
- * Original written for old namespace
79
- * http://www.topologi.com/resources/iso-pre-pro.xsl
80
- -->
81
- <xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
82
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
83
- xmlns:iso="http://purl.oclc.org/dsdl/schematron"
84
- xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
85
-
86
- xmlns:iae="http://www.schematron.com/namespace/iae"
87
-
88
- >
89
-
90
- <xslt:param name="schema-id"></xslt:param>
91
-
92
-
93
- <!-- Driver for the mode -->
94
- <xsl:template match="/">
95
- <xsl:apply-templates select="." mode="iae:go" />
96
- </xsl:template>
97
-
98
-
99
- <!-- ================================================================================== -->
100
- <!-- Normal processing rules -->
101
- <!-- ================================================================================== -->
102
- <!-- Output only the selected schema -->
103
- <xslt:template match="iso:schema" >
104
- <xsl:if test="string-length($schema-id) =0 or @id= $schema-id ">
105
- <xslt:copy>
106
- <xslt:copy-of select="@*" />
107
- <xslt:apply-templates mode="iae:go" />
108
- </xslt:copy>
109
- </xsl:if>
110
- </xslt:template>
111
-
112
-
113
- <!-- Strip out any foreign elements above the Schematron schema .
114
- -->
115
- <xslt:template match="*[not(ancestor-or-self::iso:*)]" mode="iae:go" >
116
- <xslt:apply-templates mode="iae:go" />
117
- </xslt:template>
118
-
119
-
120
- <!-- ================================================================================== -->
121
- <!-- Handle Schematron abstract pattern preprocessing -->
122
- <!-- abstract-to-real calls
123
- do-pattern calls
124
- macro-expand calls
125
- multi-macro-expand
126
- replace-substring -->
127
- <!-- ================================================================================== -->
128
-
129
- <!--
130
- Abstract patterns allow you to say, for example
131
-
132
- <pattern name="htmlTable" is-a="table">
133
- <param name="row" value="html:tr"/>
134
- <param name="cell" value="html:td" />
135
- <param name="table" value="html:table" />
136
- </pattern>
137
-
138
- For a good introduction, see Uche Ogbujii's article for IBM DeveloperWorks
139
- "Discover the flexibility of Schematron abstract patterns"
140
- http://www-128.ibm.com/developerworks/xml/library/x-stron.html
141
- However, note that ISO Schematron uses @name and @value attributes on
142
- the iso:param element, and @id not @name on the pattern element.
143
-
144
- -->
145
-
146
- <!-- Suppress declarations of abstract patterns -->
147
- <xslt:template match="iso:pattern[@abstract='true']" mode="iae:go" >
148
- <xslt:comment>Suppressed abstract pattern <xslt:value-of select="@id"/> was here</xslt:comment>
149
- </xslt:template>
150
-
151
-
152
- <!-- Suppress uses of abstract patterns -->
153
- <xslt:template match="iso:pattern[@is-a]" mode="iae:go" >
154
-
155
- <xslt:comment>Start pattern based on abstract <xslt:value-of select="@is-a"/></xslt:comment>
156
-
157
- <xslt:call-template name="iae:abstract-to-real" >
158
- <xslt:with-param name="caller" select="@id" />
159
- <xslt:with-param name="is-a" select="@is-a" />
160
- </xslt:call-template>
161
-
162
- </xslt:template>
163
-
164
-
165
-
166
- <!-- output everything else unchanged -->
167
- <xslt:template match="*" priority="-1" mode="iae:go" >
168
- <xslt:copy>
169
- <xslt:copy-of select="@*" />
170
- <xslt:apply-templates mode="iae:go"/>
171
- </xslt:copy>
172
- </xslt:template>
173
-
174
- <!-- Templates for macro expansion of abstract patterns -->
175
- <!-- Sets up the initial conditions for the recursive call -->
176
- <xslt:template name="iae:macro-expand">
177
- <xslt:param name="caller"/>
178
- <xslt:param name="text" />
179
- <xslt:call-template name="iae:multi-macro-expand">
180
- <xslt:with-param name="caller" select="$caller"/>
181
- <xslt:with-param name="text" select="$text"/>
182
- <xslt:with-param name="paramNumber" select="1"/>
183
- </xslt:call-template>
184
-
185
- </xslt:template>
186
-
187
- <!-- Template to replace the current parameter and then
188
- recurse to replace subsequent parameters. -->
189
-
190
- <xslt:template name="iae:multi-macro-expand">
191
- <xslt:param name="caller"/>
192
- <xslt:param name="text" />
193
- <xslt:param name="paramNumber" />
194
-
195
-
196
- <xslt:choose>
197
- <xslt:when test="//iso:pattern[@id=$caller]/iso:param[ $paramNumber]">
198
-
199
- <xslt:call-template name="iae:multi-macro-expand">
200
- <xslt:with-param name="caller" select="$caller"/>
201
- <xslt:with-param name="paramNumber" select="$paramNumber + 1"/>
202
- <xslt:with-param name="text" >
203
- <xslt:call-template name="iae:replace-substring">
204
- <xslt:with-param name="original" select="$text"/>
205
- <xslt:with-param name="substring"
206
- select="concat('$', //iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@name)"/>
207
- <xslt:with-param name="replacement"
208
- select="//iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@value"/>
209
- </xslt:call-template>
210
- </xslt:with-param>
211
- </xslt:call-template>
212
- </xslt:when>
213
- <xslt:otherwise><xslt:value-of select="$text" /></xslt:otherwise>
214
-
215
- </xslt:choose>
216
- </xslt:template>
217
-
218
-
219
- <!-- generate the real pattern from an abstract pattern + parameters-->
220
- <xslt:template name="iae:abstract-to-real" >
221
- <xslt:param name="caller"/>
222
- <xslt:param name="is-a" />
223
- <xslt:for-each select="//iso:pattern[@id= $is-a]">
224
- <xslt:copy>
225
-
226
- <xslt:choose>
227
- <xslt:when test=" string-length( $caller ) = 0">
228
- <xslt:attribute name="id"><xslt:value-of select="concat( generate-id(.) , $is-a)" /></xslt:attribute>
229
- </xslt:when>
230
- <xslt:otherwise>
231
- <xslt:attribute name="id"><xslt:value-of select="$caller" /></xslt:attribute>
232
- </xslt:otherwise>
233
- </xslt:choose>
234
-
235
- <xslt:apply-templates select="*|text()" mode="iae:do-pattern" >
236
- <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
237
- </xslt:apply-templates>
238
-
239
- </xslt:copy>
240
- </xslt:for-each>
241
- </xslt:template>
242
-
243
-
244
- <!-- Generate a non-abstract pattern -->
245
- <xslt:template mode="iae:do-pattern" match="*">
246
- <xslt:param name="caller"/>
247
- <xslt:copy>
248
- <xslt:for-each select="@*[name()='test' or name()='context' or name()='select' or name()='path' ]">
249
- <xslt:attribute name="{name()}">
250
- <xslt:call-template name="iae:macro-expand">
251
- <xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
252
- <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
253
- </xslt:call-template>
254
- </xslt:attribute>
255
- </xslt:for-each>
256
- <xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select'][name()!='path']" />
257
- <xsl:for-each select="node()">
258
- <xsl:choose>
259
- <!-- Experiment: replace macros in text as well, to allow parameterized assertions
260
- and so on, without having to have spurious <iso:value-of> calls and multiple
261
- delimiting.
262
- NOTE: THIS FUNCTIONALITY WILL BE REMOVED IN THE FUTURE -->
263
- <xsl:when test="self::text()">
264
- <xslt:call-template name="iae:macro-expand">
265
- <xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
266
- <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
267
- </xslt:call-template>
268
- </xsl:when>
269
- <xsl:otherwise>
270
- <xslt:apply-templates select="." mode="iae:do-pattern">
271
- <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
272
- </xslt:apply-templates>
273
- </xsl:otherwise>
274
- </xsl:choose>
275
- </xsl:for-each>
276
- </xslt:copy>
277
- </xslt:template>
278
-
279
- <!-- UTILITIES -->
280
- <!-- Simple version of replace-substring function -->
281
- <xslt:template name="iae:replace-substring">
282
- <xslt:param name="original" />
283
- <xslt:param name="substring" />
284
- <xslt:param name="replacement" select="''"/>
285
-
286
- <xsl:choose>
287
- <xsl:when test="not($original)" />
288
- <xsl:when test="not(string($substring))">
289
- <xsl:value-of select="$original" />
290
- </xsl:when>
291
- <xsl:when test="contains($original, $substring)">
292
- <xsl:variable name="before" select="substring-before($original, $substring)" />
293
- <xsl:variable name="after" select="substring-after($original, $substring)" />
294
-
295
- <xsl:value-of select="$before" />
296
- <xsl:value-of select="$replacement" />
297
- <!-- recursion -->
298
- <xsl:call-template name="iae:replace-substring">
299
- <xsl:with-param name="original" select="$after" />
300
- <xsl:with-param name="substring" select="$substring" />
301
- <xsl:with-param name="replacement" select="$replacement" />
302
- </xsl:call-template>
303
- </xsl:when>
304
- <xsl:otherwise>
305
- <!-- no substitution -->
306
- <xsl:value-of select="$original" />
307
- </xsl:otherwise>
308
- </xsl:choose>
309
- </xslt:template>
310
-
311
-
312
-
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
+ * allows parameter substitution inside @context, @test, @select, @path
11
+ * experimentally, allows parameter recognition and substitution inside
12
+ text (NOTE: to be removed, for compataibility with other implementations,
13
+ please do not use this)
14
+
15
+ This should be used after iso-dsdl-include.xsl and before the skeleton or
16
+ meta-stylesheet (e.g. iso-svrl.xsl) . It only requires XSLT 1.
17
+
18
+ Each kind of inclusion can be turned off (or on) on the command line.
19
+
20
+ -->
21
+
22
+ <!--
23
+ Open Source Initiative OSI - The MIT License:Licensing
24
+ [OSI Approved License]
25
+
26
+ This source code was previously available under the zlib/libpng license.
27
+ Attribution is polite.
28
+
29
+ The MIT License
30
+
31
+ Copyright (c) 2004-2010 Rick Jellife and Academia Sinica Computing Centre, Taiwan
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy
34
+ of this software and associated documentation files (the "Software"), to deal
35
+ in the Software without restriction, including without limitation the rights
36
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
+ copies of the Software, and to permit persons to whom the Software is
38
+ furnished to do so, subject to the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included in
41
+ all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49
+ THE SOFTWARE.
50
+ -->
51
+
52
+ <!--
53
+ VERSION INFORMATION
54
+ 2013-09-19 RJ
55
+ * Allow macro expansion in @path attributes, eg. for sch:name/@path
56
+
57
+ 2010-07-10 RJ
58
+ * Move to MIT license
59
+
60
+ 2008-09-18 RJ
61
+ * move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
62
+
63
+ 2008-07-29 RJ
64
+ * Create. Pull out as distinct XSL in its own namespace from old iso_pre_pro.xsl
65
+ * Put everything in private namespace
66
+ * Rewrite replace_substring named template so that copyright is clear
67
+
68
+ 2008-07-24 RJ
69
+ * correct abstract patterns so for correct names: param/@name and
70
+ param/@value
71
+
72
+ 2007-01-12 RJ
73
+ * Use ISO namespace
74
+ * Use pattern/@id not pattern/@name
75
+ * Add Oliver Becker's suggests from old Schematron-love-in list for <copy>
76
+ * Add XT -ism?
77
+ 2003 RJ
78
+ * Original written for old namespace
79
+ * http://www.topologi.com/resources/iso-pre-pro.xsl
80
+ -->
81
+ <xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
82
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
83
+ xmlns:iso="http://purl.oclc.org/dsdl/schematron"
84
+ xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
85
+
86
+ xmlns:iae="http://www.schematron.com/namespace/iae"
87
+
88
+ >
89
+
90
+ <xslt:param name="schema-id"></xslt:param>
91
+
92
+
93
+ <!-- Driver for the mode -->
94
+ <xsl:template match="/">
95
+ <xsl:apply-templates select="." mode="iae:go" />
96
+ </xsl:template>
97
+
98
+
99
+ <!-- ================================================================================== -->
100
+ <!-- Normal processing rules -->
101
+ <!-- ================================================================================== -->
102
+ <!-- Output only the selected schema -->
103
+ <xslt:template match="iso:schema" >
104
+ <xsl:if test="string-length($schema-id) =0 or @id= $schema-id ">
105
+ <xslt:copy>
106
+ <xslt:copy-of select="@*" />
107
+ <xslt:apply-templates mode="iae:go" />
108
+ </xslt:copy>
109
+ </xsl:if>
110
+ </xslt:template>
111
+
112
+
113
+ <!-- Strip out any foreign elements above the Schematron schema .
114
+ -->
115
+ <xslt:template match="*[not(ancestor-or-self::iso:*)]" mode="iae:go" >
116
+ <xslt:apply-templates mode="iae:go" />
117
+ </xslt:template>
118
+
119
+
120
+ <!-- ================================================================================== -->
121
+ <!-- Handle Schematron abstract pattern preprocessing -->
122
+ <!-- abstract-to-real calls
123
+ do-pattern calls
124
+ macro-expand calls
125
+ multi-macro-expand
126
+ replace-substring -->
127
+ <!-- ================================================================================== -->
128
+
129
+ <!--
130
+ Abstract patterns allow you to say, for example
131
+
132
+ <pattern name="htmlTable" is-a="table">
133
+ <param name="row" value="html:tr"/>
134
+ <param name="cell" value="html:td" />
135
+ <param name="table" value="html:table" />
136
+ </pattern>
137
+
138
+ For a good introduction, see Uche Ogbujii's article for IBM DeveloperWorks
139
+ "Discover the flexibility of Schematron abstract patterns"
140
+ http://www-128.ibm.com/developerworks/xml/library/x-stron.html
141
+ However, note that ISO Schematron uses @name and @value attributes on
142
+ the iso:param element, and @id not @name on the pattern element.
143
+
144
+ -->
145
+
146
+ <!-- Suppress declarations of abstract patterns -->
147
+ <xslt:template match="iso:pattern[@abstract='true']" mode="iae:go" >
148
+ <xslt:comment>Suppressed abstract pattern <xslt:value-of select="@id"/> was here</xslt:comment>
149
+ </xslt:template>
150
+
151
+
152
+ <!-- Suppress uses of abstract patterns -->
153
+ <xslt:template match="iso:pattern[@is-a]" mode="iae:go" >
154
+
155
+ <xslt:comment>Start pattern based on abstract <xslt:value-of select="@is-a"/></xslt:comment>
156
+
157
+ <xslt:call-template name="iae:abstract-to-real" >
158
+ <xslt:with-param name="caller" select="@id" />
159
+ <xslt:with-param name="is-a" select="@is-a" />
160
+ </xslt:call-template>
161
+
162
+ </xslt:template>
163
+
164
+
165
+
166
+ <!-- output everything else unchanged -->
167
+ <xslt:template match="*" priority="-1" mode="iae:go" >
168
+ <xslt:copy>
169
+ <xslt:copy-of select="@*" />
170
+ <xslt:apply-templates mode="iae:go"/>
171
+ </xslt:copy>
172
+ </xslt:template>
173
+
174
+ <!-- Templates for macro expansion of abstract patterns -->
175
+ <!-- Sets up the initial conditions for the recursive call -->
176
+ <xslt:template name="iae:macro-expand">
177
+ <xslt:param name="caller"/>
178
+ <xslt:param name="text" />
179
+ <xslt:call-template name="iae:multi-macro-expand">
180
+ <xslt:with-param name="caller" select="$caller"/>
181
+ <xslt:with-param name="text" select="$text"/>
182
+ <xslt:with-param name="paramNumber" select="1"/>
183
+ </xslt:call-template>
184
+
185
+ </xslt:template>
186
+
187
+ <!-- Template to replace the current parameter and then
188
+ recurse to replace subsequent parameters. -->
189
+
190
+ <xslt:template name="iae:multi-macro-expand">
191
+ <xslt:param name="caller"/>
192
+ <xslt:param name="text" />
193
+ <xslt:param name="paramNumber" />
194
+
195
+
196
+ <xslt:choose>
197
+ <xslt:when test="//iso:pattern[@id=$caller]/iso:param[ $paramNumber]">
198
+
199
+ <xslt:call-template name="iae:multi-macro-expand">
200
+ <xslt:with-param name="caller" select="$caller"/>
201
+ <xslt:with-param name="paramNumber" select="$paramNumber + 1"/>
202
+ <xslt:with-param name="text" >
203
+ <xslt:call-template name="iae:replace-substring">
204
+ <xslt:with-param name="original" select="$text"/>
205
+ <xslt:with-param name="substring"
206
+ select="concat('$', //iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@name)"/>
207
+ <xslt:with-param name="replacement"
208
+ select="//iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@value"/>
209
+ </xslt:call-template>
210
+ </xslt:with-param>
211
+ </xslt:call-template>
212
+ </xslt:when>
213
+ <xslt:otherwise><xslt:value-of select="$text" /></xslt:otherwise>
214
+
215
+ </xslt:choose>
216
+ </xslt:template>
217
+
218
+
219
+ <!-- generate the real pattern from an abstract pattern + parameters-->
220
+ <xslt:template name="iae:abstract-to-real" >
221
+ <xslt:param name="caller"/>
222
+ <xslt:param name="is-a" />
223
+ <xslt:for-each select="//iso:pattern[@id= $is-a]">
224
+ <xslt:copy>
225
+
226
+ <xslt:choose>
227
+ <xslt:when test=" string-length( $caller ) = 0">
228
+ <xslt:attribute name="id"><xslt:value-of select="concat( generate-id(.) , $is-a)" /></xslt:attribute>
229
+ </xslt:when>
230
+ <xslt:otherwise>
231
+ <xslt:attribute name="id"><xslt:value-of select="$caller" /></xslt:attribute>
232
+ </xslt:otherwise>
233
+ </xslt:choose>
234
+
235
+ <xslt:apply-templates select="*|text()" mode="iae:do-pattern" >
236
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
237
+ </xslt:apply-templates>
238
+
239
+ </xslt:copy>
240
+ </xslt:for-each>
241
+ </xslt:template>
242
+
243
+
244
+ <!-- Generate a non-abstract pattern -->
245
+ <xslt:template mode="iae:do-pattern" match="*">
246
+ <xslt:param name="caller"/>
247
+ <xslt:copy>
248
+ <xslt:for-each select="@*[name()='test' or name()='context' or name()='select' or name()='path' ]">
249
+ <xslt:attribute name="{name()}">
250
+ <xslt:call-template name="iae:macro-expand">
251
+ <xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
252
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
253
+ </xslt:call-template>
254
+ </xslt:attribute>
255
+ </xslt:for-each>
256
+ <xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select'][name()!='path']" />
257
+ <xsl:for-each select="node()">
258
+ <xsl:choose>
259
+ <!-- Experiment: replace macros in text as well, to allow parameterized assertions
260
+ and so on, without having to have spurious <iso:value-of> calls and multiple
261
+ delimiting.
262
+ NOTE: THIS FUNCTIONALITY WILL BE REMOVED IN THE FUTURE -->
263
+ <xsl:when test="self::text()">
264
+ <xslt:call-template name="iae:macro-expand">
265
+ <xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
266
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
267
+ </xslt:call-template>
268
+ </xsl:when>
269
+ <xsl:otherwise>
270
+ <xslt:apply-templates select="." mode="iae:do-pattern">
271
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
272
+ </xslt:apply-templates>
273
+ </xsl:otherwise>
274
+ </xsl:choose>
275
+ </xsl:for-each>
276
+ </xslt:copy>
277
+ </xslt:template>
278
+
279
+ <!-- UTILITIES -->
280
+ <!-- Simple version of replace-substring function -->
281
+ <xslt:template name="iae:replace-substring">
282
+ <xslt:param name="original" />
283
+ <xslt:param name="substring" />
284
+ <xslt:param name="replacement" select="''"/>
285
+
286
+ <xsl:choose>
287
+ <xsl:when test="not($original)" />
288
+ <xsl:when test="not(string($substring))">
289
+ <xsl:value-of select="$original" />
290
+ </xsl:when>
291
+ <xsl:when test="contains($original, $substring)">
292
+ <xsl:variable name="before" select="substring-before($original, $substring)" />
293
+ <xsl:variable name="after" select="substring-after($original, $substring)" />
294
+
295
+ <xsl:value-of select="$before" />
296
+ <xsl:value-of select="$replacement" />
297
+ <!-- recursion -->
298
+ <xsl:call-template name="iae:replace-substring">
299
+ <xsl:with-param name="original" select="$after" />
300
+ <xsl:with-param name="substring" select="$substring" />
301
+ <xsl:with-param name="replacement" select="$replacement" />
302
+ </xsl:call-template>
303
+ </xsl:when>
304
+ <xsl:otherwise>
305
+ <!-- no substitution -->
306
+ <xsl:value-of select="$original" />
307
+ </xsl:otherwise>
308
+ </xsl:choose>
309
+ </xslt:template>
310
+
311
+
312
+
313
313
  </xslt:stylesheet>