flazz-schematron 0.0.0 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +21 -0
- data/README +3 -0
- data/bin/stron +27 -0
- data/iso_impl/iso_abstract_expand.xsl +295 -0
- data/iso_impl/iso_dsdl_include.xsl +989 -0
- data/iso_impl/iso_schematron_skeleton_for_saxon.xsl +1884 -0
- data/iso_impl/iso_schematron_skeleton_for_xslt1.xsl +1749 -0
- data/iso_impl/iso_schematron_text.xsl +126 -0
- data/iso_impl/iso_svrl.xsl +583 -0
- data/lib/schematron.rb +67 -0
- data/schematron.gemspec +30 -6
- data/spec/command_spec.rb +22 -0
- data/spec/feature_requests_spec.rb +5 -0
- data/spec/instances/daitss-sip/Example1.xml +37 -0
- data/spec/instances/daitss-sip/Example2.xml +68 -0
- data/spec/instances/premis-in-mets/bad.xml +102 -0
- data/spec/instances/premis-in-mets/good.xml +103 -0
- data/spec/schema/fda_sip.sch +72 -0
- data/spec/schema/pim.sch +27 -0
- data/spec/schema_spec.rb +43 -0
- data/spec/spec_helper.rb +1 -0
- metadata +51 -10
- data/bin/validate +0 -57
- data/bin/validate-sh +0 -9
@@ -0,0 +1,989 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><?xar XSLT?>
|
2
|
+
|
3
|
+
<!--
|
4
|
+
OVERVIEW : iso_dsdl_include.xsl
|
5
|
+
|
6
|
+
This is an inclusion preprocessor for the non-smart text inclusions
|
7
|
+
of ISO DSDL. It handles
|
8
|
+
<relax:extRef> for ISO RELAX NG
|
9
|
+
<sch:include> for ISO Schematron and Schematron 1.n
|
10
|
+
<xi:xinclude> simple W3C XIncludes for ISO NVRL and DSRL
|
11
|
+
<crdl:ref> for draft ISO CRDL
|
12
|
+
<dtll:include> for draft ISO DTLL
|
13
|
+
<* @xlink:href> for simple W3C XLink 1.1 embedded links
|
14
|
+
|
15
|
+
|
16
|
+
This should be the first in any chain of processing. It only requires
|
17
|
+
XSLT 1. Each kind of inclusion can be turned off (or on) on the command line.
|
18
|
+
|
19
|
+
Ids in fragment identifiers or xpointers will be sought in the following
|
20
|
+
order:
|
21
|
+
* @xml:id
|
22
|
+
* id() for typed schemas (e.g. from DTD) [NOTE: XInclude does not support this]
|
23
|
+
* untyped @id
|
24
|
+
|
25
|
+
The proposed behaviour for the update to ISO Schematron has been implemented. If an
|
26
|
+
include points to an element with the same name as the parent, then that element's
|
27
|
+
contents will be included. This supports the merge style of inclusion.
|
28
|
+
|
29
|
+
When an inclusion is made, it is preceded by a PI with target DSDL_INCLUDE_START
|
30
|
+
and the href and closed by a PI with target DSDL_INCLUDE_START and the href. This is
|
31
|
+
to allow better location of problems, though only to the file level.
|
32
|
+
|
33
|
+
Limitations:
|
34
|
+
* No rebasing: relative paths will be interpreted based on the initial document's
|
35
|
+
path, not the including document. (Severe limitation!)
|
36
|
+
* No checking for circular references
|
37
|
+
* Not full xpointers: only ID matching
|
38
|
+
* <relax:include> not implemented
|
39
|
+
* XInclude handling of xml:base and xml:lang not implemented
|
40
|
+
-->
|
41
|
+
<!--
|
42
|
+
VERSION INFORMATION
|
43
|
+
2008-09-18
|
44
|
+
* Remove new behaviour for include, because it conflicts with existing usage [KH]
|
45
|
+
* Add extends[@href] element with that merge functionality
|
46
|
+
* Generate PIs to notate source of inclusions for potential better diagnostics
|
47
|
+
|
48
|
+
2008-09-16
|
49
|
+
* Fix for XSLT1
|
50
|
+
|
51
|
+
2008-08-28
|
52
|
+
* New behaviour for schematron includes: if the pointed to element is the same as the current,
|
53
|
+
include the children.
|
54
|
+
|
55
|
+
2008-08-20
|
56
|
+
* Fix bug: in XSLT1 cannot do $document/id('x') but need to use for-each
|
57
|
+
|
58
|
+
2008-08-04
|
59
|
+
* Add support for inclusions in old namespace
|
60
|
+
|
61
|
+
2008-08-03
|
62
|
+
* Fix wrong param name include-relaxng & include-crdl (KH, PH)
|
63
|
+
* Allow inclusion of XSLT and XHTML (KH)
|
64
|
+
* Fix inclusion of fragments (KH)
|
65
|
+
|
66
|
+
2008-07-25
|
67
|
+
* Add selectable input parameter
|
68
|
+
|
69
|
+
2008-07-24
|
70
|
+
* RJ New
|
71
|
+
-->
|
72
|
+
<!--
|
73
|
+
LEGAL INFORMATION
|
74
|
+
|
75
|
+
Copyright (c) 2008 Rick Jelliffe
|
76
|
+
|
77
|
+
This software is provided 'as-is', without any express or implied warranty.
|
78
|
+
In no event will the authors be held liable for any damages arising from
|
79
|
+
the use of this software.
|
80
|
+
|
81
|
+
Permission is granted to anyone to use this software for any purpose,
|
82
|
+
including commercial applications, and to alter it and redistribute it freely,
|
83
|
+
subject to the following restrictions:
|
84
|
+
|
85
|
+
1. The origin of this software must not be misrepresented; you must not claim
|
86
|
+
that you wrote the original software. If you use this software in a product,
|
87
|
+
an acknowledgment in the product documentation would be appreciated but is
|
88
|
+
not required.
|
89
|
+
|
90
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
91
|
+
misrepresented as being the original software.
|
92
|
+
|
93
|
+
3. This notice may not be removed or altered from any source distribution.
|
94
|
+
-->
|
95
|
+
<xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
|
96
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
97
|
+
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
|
98
|
+
xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
|
99
|
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
100
|
+
xmlns:schold="http://www.ascc.net/xml/schematron"
|
101
|
+
xmlns:crdl="http://purl.oclc.org/dsdl/crepdl/ns/structure/1.0"
|
102
|
+
xmlns:xi="http://www.w3.org/2001/XInclude"
|
103
|
+
xmlns:dtll="http://www.jenitennison.com/datatypes"
|
104
|
+
xmlns:dsdl="http://www.dsdl.org/namespace"
|
105
|
+
xmlns:relax="http://relaxng.org/ns/structure/1.0"
|
106
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
107
|
+
>
|
108
|
+
<!-- Note: The URL for the dsdl namespace is not official -->
|
109
|
+
|
110
|
+
|
111
|
+
<xsl:param name="include-schematron">true</xsl:param>
|
112
|
+
<xsl:param name="include-crdl">true</xsl:param>
|
113
|
+
<xsl:param name="include-xinclude">true</xsl:param>
|
114
|
+
<xsl:param name="include-dtll">true</xsl:param>
|
115
|
+
<xsl:param name="include-relaxng">true</xsl:param>
|
116
|
+
<xsl:param name="include-xlink">true</xsl:param>
|
117
|
+
|
118
|
+
<xsl:template match="/">
|
119
|
+
<xsl:apply-templates select="." mode="dsdl:go" />
|
120
|
+
</xsl:template>
|
121
|
+
|
122
|
+
<!-- output everything else unchanged -->
|
123
|
+
<xslt:template match="node()" priority="-1" mode="dsdl:go">
|
124
|
+
<xslt:copy>
|
125
|
+
<xslt:copy-of select="@*" />
|
126
|
+
<xslt:apply-templates mode="dsdl:go" />
|
127
|
+
</xslt:copy>
|
128
|
+
</xslt:template>
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
<!-- =========================================================== -->
|
133
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
134
|
+
<!-- Part 2 - Regular grammar-based validation - RELAX NG -->
|
135
|
+
<!-- This only implements relax:extRef not relax:include which -->
|
136
|
+
<!-- is complex. -->
|
137
|
+
<!-- =========================================================== -->
|
138
|
+
<xslt:template match="relax:extRef" mode="dsdl:go">
|
139
|
+
|
140
|
+
|
141
|
+
<!-- Insert subschema -->
|
142
|
+
|
143
|
+
<xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
|
144
|
+
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
|
145
|
+
|
146
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
147
|
+
<xsl:choose>
|
148
|
+
<xsl:when test="not( $include-relaxng = 'true' )">
|
149
|
+
<xslt:copy>
|
150
|
+
<xslt:copy-of select="@*" />
|
151
|
+
<xslt:apply-templates mode="dsdl:go" />
|
152
|
+
</xslt:copy>
|
153
|
+
</xsl:when>
|
154
|
+
<xsl:otherwise>
|
155
|
+
|
156
|
+
<xsl:choose>
|
157
|
+
|
158
|
+
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
|
159
|
+
<xsl:message>Error: Impossible URL in RELAX NG extRef include</xsl:message>
|
160
|
+
</xsl:when>
|
161
|
+
|
162
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
163
|
+
<xslt:when test="string-length( $document-uri ) = 0">
|
164
|
+
<xslt:apply-templates mode="dsdl:go"
|
165
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id) | //*[@id= $fragment-id ]"/>
|
166
|
+
</xslt:when>
|
167
|
+
|
168
|
+
<xsl:when test="string-length( $fragment-id ) > 0">
|
169
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
170
|
+
|
171
|
+
<xsl:if test="not($theDocument)">
|
172
|
+
<xsl:message terminate="no">
|
173
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
174
|
+
<xsl:value-of select="@href"/>
|
175
|
+
</xsl:message>
|
176
|
+
</xsl:if>
|
177
|
+
<!-- use a for-each so that the id() function works correctly on the external document -->
|
178
|
+
<xsl:for-each select="$theDocument">
|
179
|
+
<xsl:variable name="theFragment" select="$theDocument//*[@xml:id= $fragment-id ]
|
180
|
+
| id( $fragment-id)
|
181
|
+
| $theDocument//*[@id= $fragment-id ]" />
|
182
|
+
<xsl:if test="not($theFragment)">
|
183
|
+
<xsl:message terminate="no">
|
184
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
185
|
+
<xsl:value-of select="@href"/>
|
186
|
+
</xsl:message>
|
187
|
+
</xsl:if>
|
188
|
+
<xsl:apply-templates select=" $theFragment[1]" mode="dsdl:go"/>
|
189
|
+
</xsl:for-each>
|
190
|
+
</xsl:when>
|
191
|
+
|
192
|
+
<xsl:otherwise>
|
193
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
194
|
+
<xsl:variable name="theFragment" select="$theDocument/*" />
|
195
|
+
<xsl:if test="not($theDocument)">
|
196
|
+
<xsl:message terminate="no">
|
197
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
198
|
+
<xsl:value-of select="@href"/>
|
199
|
+
</xsl:message>
|
200
|
+
</xsl:if>
|
201
|
+
|
202
|
+
<xsl:if test="not($theFragment)">
|
203
|
+
<xsl:message terminate="no">
|
204
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
205
|
+
<xsl:value-of select="@href"/>
|
206
|
+
</xsl:message>
|
207
|
+
</xsl:if>
|
208
|
+
<xsl:apply-templates select="$theFragment " mode="dsdl:go"/>
|
209
|
+
</xsl:otherwise>
|
210
|
+
</xsl:choose>
|
211
|
+
|
212
|
+
</xsl:otherwise>
|
213
|
+
</xsl:choose>
|
214
|
+
|
215
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
216
|
+
</xslt:template>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
<!-- =========================================================== -->
|
221
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
222
|
+
<!-- Part 3 - Rule-based validation - Schematron -->
|
223
|
+
<!-- =========================================================== -->
|
224
|
+
|
225
|
+
|
226
|
+
<!-- Extend the URI syntax to allow # references -->
|
227
|
+
<!-- Add experimental support for simple containers like /xxx:xxx/iso:pattern to allow better includes -->
|
228
|
+
<xsl:template match="iso:include" mode="dsdl:go">
|
229
|
+
|
230
|
+
<xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
|
231
|
+
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
|
232
|
+
|
233
|
+
|
234
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
235
|
+
|
236
|
+
<xsl:choose>
|
237
|
+
<xsl:when test="not( $include-schematron = 'true' )">
|
238
|
+
<xslt:copy>
|
239
|
+
<xslt:copy-of select="@*" />
|
240
|
+
<xslt:apply-templates mode="dsdl:go" />
|
241
|
+
</xslt:copy>
|
242
|
+
</xsl:when>
|
243
|
+
<xsl:otherwise>
|
244
|
+
|
245
|
+
<xsl:choose>
|
246
|
+
|
247
|
+
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
|
248
|
+
<xsl:message>Error: Impossible URL in Schematron include</xsl:message>
|
249
|
+
</xsl:when>
|
250
|
+
|
251
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
252
|
+
<xslt:when test="string-length( $document-uri ) = 0">
|
253
|
+
<xslt:apply-templates mode="dsdl:go"
|
254
|
+
select="//iso:*[@xml:id= $fragment-id ]
|
255
|
+
|id( $fragment-id)
|
256
|
+
| //iso:*[@id= $fragment-id ]"/>
|
257
|
+
</xslt:when>
|
258
|
+
|
259
|
+
<!-- case where there is a fragment in another document (should be an iso: element) -->
|
260
|
+
<!-- There are three cases for includes with fragment:
|
261
|
+
0) No href file or no matching id - error!
|
262
|
+
1) REMOVED
|
263
|
+
|
264
|
+
2) The linked-to element is sch:schema however the parent of the include
|
265
|
+
is not a schema. In this case, it is an error. (Actually, it should
|
266
|
+
be an error for other kinds of containment problems, but we won't
|
267
|
+
check for them in this version.)
|
268
|
+
|
269
|
+
3) Otherwise, include the pointed-to element
|
270
|
+
-->
|
271
|
+
|
272
|
+
<xsl:when test="string-length( $fragment-id ) > 0">
|
273
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
274
|
+
<xsl:variable name="originalParent" select=".." />
|
275
|
+
|
276
|
+
<!-- case 0 -->
|
277
|
+
<xsl:if test="not($theDocument)">
|
278
|
+
<xsl:message terminate="no">
|
279
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
280
|
+
<xsl:value-of select="@href"/>
|
281
|
+
</xsl:message>
|
282
|
+
</xsl:if>
|
283
|
+
<!-- use for-each to rebase id() to external document -->
|
284
|
+
<xsl:for-each select="$theDocument" >
|
285
|
+
<xsl:variable name="theFragment"
|
286
|
+
select=" $theDocument//iso:*[@xml:id= $fragment-id ] |
|
287
|
+
id($fragment-id) |
|
288
|
+
$theDocument//iso:*[@id= $fragment-id ]" />
|
289
|
+
|
290
|
+
|
291
|
+
<xsl:choose>
|
292
|
+
<!-- case 0 -->
|
293
|
+
<xsl:when test="not($theFragment)">
|
294
|
+
<xsl:message terminate="no">
|
295
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
296
|
+
<xsl:value-of select="@href"/>
|
297
|
+
</xsl:message>
|
298
|
+
</xsl:when>
|
299
|
+
|
300
|
+
|
301
|
+
<!-- case 1 REMOVED -->
|
302
|
+
|
303
|
+
<!-- case 2 -->
|
304
|
+
<xsl:when test=" $theFragment/self::iso:schema ">
|
305
|
+
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
306
|
+
</xsl:when>
|
307
|
+
|
308
|
+
<!-- case 3 -->
|
309
|
+
<xsl:otherwise>
|
310
|
+
<xsl:apply-templates select=" $theFragment[1]" mode="dsdl:go"/>
|
311
|
+
</xsl:otherwise>
|
312
|
+
</xsl:choose>
|
313
|
+
</xsl:for-each>
|
314
|
+
</xsl:when>
|
315
|
+
|
316
|
+
<!-- Case where there is no ID so we include the whole document -->
|
317
|
+
<!-- Experimental addition: include fragments of children -->
|
318
|
+
<xsl:otherwise>
|
319
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
320
|
+
<xsl:variable name="theFragment" select="$theDocument/iso:*" />
|
321
|
+
<xsl:variable name="theContainedFragments" select="$theDocument/*/iso:* | $theDocument/*/xsl:* | $theDocument/*/xhtml:*" />
|
322
|
+
<xsl:if test="not($theDocument)">
|
323
|
+
<xsl:message terminate="no">
|
324
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
325
|
+
<xsl:value-of select="@href"/>
|
326
|
+
</xsl:message>
|
327
|
+
</xsl:if>
|
328
|
+
|
329
|
+
<!-- There are three cases for includes:
|
330
|
+
0) No text specified- error!
|
331
|
+
|
332
|
+
1) REMOVED
|
333
|
+
|
334
|
+
2) The linked-to element is sch:schema however the parent of the include
|
335
|
+
is not a schema. In this case, it is an error. (Actually, it should
|
336
|
+
be an error for other kinds of containment problems, but we won't
|
337
|
+
check for them in this version.)
|
338
|
+
|
339
|
+
3) Otherwise, include the pointed-to element
|
340
|
+
-->
|
341
|
+
<xsl:choose>
|
342
|
+
<!-- case 0 -->
|
343
|
+
<xsl:when test="not($theFragment) and not ($theContainedFragments)">
|
344
|
+
<xsl:message terminate="no">
|
345
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
346
|
+
<xsl:value-of select="@href"/>
|
347
|
+
</xsl:message>
|
348
|
+
</xsl:when>
|
349
|
+
|
350
|
+
<!-- case 1 removed -->
|
351
|
+
|
352
|
+
<!-- case 2 -->
|
353
|
+
<xsl:when test=" $theFragment/self::iso:schema or $theContainedFragments/self::iso:schema">
|
354
|
+
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
355
|
+
</xsl:when>
|
356
|
+
|
357
|
+
<!-- If this were XLST 2, we could use
|
358
|
+
if ($theFragment) then $theFragment else $theContainedFragments
|
359
|
+
here (thanks to KN)
|
360
|
+
-->
|
361
|
+
<!-- case 3 -->
|
362
|
+
<xsl:otherwise>
|
363
|
+
<xsl:apply-templates select="$theFragment " mode="dsdl:go"/>
|
364
|
+
</xsl:otherwise>
|
365
|
+
</xsl:choose>
|
366
|
+
</xsl:otherwise>
|
367
|
+
</xsl:choose>
|
368
|
+
</xsl:otherwise>
|
369
|
+
</xsl:choose>
|
370
|
+
|
371
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
372
|
+
</xsl:template>
|
373
|
+
|
374
|
+
|
375
|
+
<!-- WARNING sch:extends[@href] is experimental and non standard -->
|
376
|
+
<!-- Basically, it adds the children of the selected element, not the element itself. -->
|
377
|
+
<xsl:template match="iso:extends[@href]" mode="dsdl:go">
|
378
|
+
|
379
|
+
<xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
|
380
|
+
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
|
381
|
+
|
382
|
+
|
383
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
384
|
+
|
385
|
+
<xsl:choose>
|
386
|
+
<xsl:when test="not( $include-schematron = 'true' )">
|
387
|
+
<xslt:copy>
|
388
|
+
<xslt:copy-of select="@*" />
|
389
|
+
<xslt:apply-templates mode="dsdl:go" />
|
390
|
+
</xslt:copy>
|
391
|
+
</xsl:when>
|
392
|
+
<xsl:otherwise>
|
393
|
+
|
394
|
+
<xsl:choose>
|
395
|
+
|
396
|
+
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
|
397
|
+
<xsl:message>Error: Impossible URL in Schematron include</xsl:message>
|
398
|
+
</xsl:when>
|
399
|
+
|
400
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
401
|
+
<xslt:when test="string-length( $document-uri ) = 0">
|
402
|
+
<xslt:apply-templates mode="dsdl:go"
|
403
|
+
select="//iso:*[@xml:id= $fragment-id ]/*
|
404
|
+
|id( $fragment-id)/*
|
405
|
+
| //iso:*[@id= $fragment-id ]/*"/>
|
406
|
+
</xslt:when>
|
407
|
+
|
408
|
+
<!-- case where there is a fragment in another document (should be an iso: element) -->
|
409
|
+
<!-- There are three cases for includes with fragment:
|
410
|
+
0) No href file or no matching id - error!
|
411
|
+
1) REMOVED
|
412
|
+
|
413
|
+
2) REMOVED
|
414
|
+
|
415
|
+
3) Otherwise, include the pointed-to element
|
416
|
+
-->
|
417
|
+
|
418
|
+
<xsl:when test="string-length( $fragment-id ) > 0">
|
419
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
420
|
+
<xsl:variable name="originalParent" select=".." />
|
421
|
+
|
422
|
+
<!-- case 0 -->
|
423
|
+
<xsl:if test="not($theDocument)">
|
424
|
+
<xsl:message terminate="no">
|
425
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
426
|
+
<xsl:value-of select="@href"/>
|
427
|
+
</xsl:message>
|
428
|
+
</xsl:if>
|
429
|
+
<!-- use for-each to rebase id() to external document -->
|
430
|
+
<xsl:for-each select="$theDocument" >
|
431
|
+
<xsl:variable name="theFragment"
|
432
|
+
select=" $theDocument//iso:*[@xml:id= $fragment-id ] |
|
433
|
+
id($fragment-id) |
|
434
|
+
$theDocument//iso:*[@id= $fragment-id ]" />
|
435
|
+
|
436
|
+
|
437
|
+
<xsl:choose>
|
438
|
+
<!-- case 0 -->
|
439
|
+
<xsl:when test="not($theFragment)">
|
440
|
+
<xsl:message terminate="no">
|
441
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
442
|
+
<xsl:value-of select="@href"/>
|
443
|
+
</xsl:message>
|
444
|
+
</xsl:when>
|
445
|
+
|
446
|
+
|
447
|
+
<!-- case 1 REMOVED -->
|
448
|
+
|
449
|
+
<!-- case 2 REMOVED -->
|
450
|
+
|
451
|
+
|
452
|
+
<!-- case 3 -->
|
453
|
+
<xsl:otherwise>
|
454
|
+
|
455
|
+
<xsl:apply-templates select=" $theFragment[1]/*" mode="dsdl:go"/>
|
456
|
+
</xsl:otherwise>
|
457
|
+
</xsl:choose>
|
458
|
+
</xsl:for-each>
|
459
|
+
</xsl:when>
|
460
|
+
|
461
|
+
<!-- Case where there is no ID so we include the whole document -->
|
462
|
+
<!-- Experimental addition: include fragments of children -->
|
463
|
+
<xsl:otherwise>
|
464
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
465
|
+
<xsl:variable name="theFragment" select="$theDocument/iso:*" />
|
466
|
+
<xsl:variable name="theContainedFragments" select="$theDocument/*/iso:* | $theDocument/*/xsl:* | $theDocument/*/xhtml:*" />
|
467
|
+
<xsl:if test="not($theDocument)">
|
468
|
+
<xsl:message terminate="no">
|
469
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
470
|
+
<xsl:value-of select="@href"/>
|
471
|
+
</xsl:message>
|
472
|
+
</xsl:if>
|
473
|
+
|
474
|
+
<!-- There are three cases for includes:
|
475
|
+
0) No text specified- error!
|
476
|
+
|
477
|
+
1) REMOVED
|
478
|
+
|
479
|
+
2) REMOVED
|
480
|
+
|
481
|
+
3) Otherwise, include the pointed-to element
|
482
|
+
-->
|
483
|
+
<xsl:choose>
|
484
|
+
<!-- case 0 -->
|
485
|
+
<xsl:when test="not($theFragment) and not ($theContainedFragments)">
|
486
|
+
<xsl:message terminate="no">
|
487
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
488
|
+
<xsl:value-of select="@href"/>
|
489
|
+
</xsl:message>
|
490
|
+
</xsl:when>
|
491
|
+
|
492
|
+
<!-- case 1 removed -->
|
493
|
+
|
494
|
+
<!-- case 2 removed -->
|
495
|
+
|
496
|
+
<!-- If this were XLST 2, we could use
|
497
|
+
if ($theFragment) then $theFragment else $theContainedFragments
|
498
|
+
here (thanks to KN)
|
499
|
+
-->
|
500
|
+
<!-- case 3 -->
|
501
|
+
<xsl:otherwise>
|
502
|
+
<xsl:apply-templates select="$theFragment/* " mode="dsdl:go"/>
|
503
|
+
</xsl:otherwise>
|
504
|
+
</xsl:choose>
|
505
|
+
</xsl:otherwise>
|
506
|
+
</xsl:choose>
|
507
|
+
</xsl:otherwise>
|
508
|
+
</xsl:choose>
|
509
|
+
|
510
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
511
|
+
</xsl:template>
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
<!-- =========================================================== -->
|
516
|
+
<!-- Handle Schematron 1.6 inclusions: clone of ISO code above -->
|
517
|
+
<!-- =========================================================== -->
|
518
|
+
|
519
|
+
|
520
|
+
<!-- Extend the URI syntax to allow # references -->
|
521
|
+
<!-- Add experimental support for simple containers like /xxx:xxx/schold:pattern to allow better includes -->
|
522
|
+
<xsl:template match="schold:include" mode="dsdl:go">
|
523
|
+
<xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
|
524
|
+
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
|
525
|
+
|
526
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
527
|
+
|
528
|
+
<xsl:choose>
|
529
|
+
<xsl:when test="not( $include-schematron = 'true' )">
|
530
|
+
<xslt:copy>
|
531
|
+
<xslt:copy-of select="@*" />
|
532
|
+
<xslt:apply-templates mode="dsdl:go" />
|
533
|
+
</xslt:copy>
|
534
|
+
</xsl:when>
|
535
|
+
<xsl:otherwise>
|
536
|
+
<xsl:choose>
|
537
|
+
|
538
|
+
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
|
539
|
+
<xsl:message>Error: Impossible URL in Schematron include</xsl:message>
|
540
|
+
</xsl:when>
|
541
|
+
|
542
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
543
|
+
<xslt:when test="string-length( $document-uri ) = 0">
|
544
|
+
<xslt:apply-templates mode="dsdl:go"
|
545
|
+
select="//schold:*[@xml:id= $fragment-id ]
|
546
|
+
|id( $fragment-id)
|
547
|
+
| //schold:*[@id= $fragment-id ]"/>
|
548
|
+
</xslt:when>
|
549
|
+
|
550
|
+
<!-- case where there is a fragment in another document (should be an iso: element) -->
|
551
|
+
<xsl:when test="string-length( $fragment-id ) > 0">
|
552
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
553
|
+
<xsl:if test="not($theDocument)">
|
554
|
+
<xsl:message terminate="no">
|
555
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
556
|
+
<xsl:value-of select="@href"/>
|
557
|
+
</xsl:message>
|
558
|
+
</xsl:if>
|
559
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
560
|
+
<xsl:for-each select="$theDocument">
|
561
|
+
<xsl:variable name="theFragment"
|
562
|
+
select=" $theDocument//schold:*[@xml:id= $fragment-id ] |
|
563
|
+
id($fragment-id) |
|
564
|
+
$theDocument//schold:*[@id= $fragment-id ]" />
|
565
|
+
<xsl:if test=" $theFragment/self::schold:schema ">
|
566
|
+
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
567
|
+
</xsl:if>
|
568
|
+
<xsl:if test="not($theFragment)">
|
569
|
+
<xsl:message terminate="no">
|
570
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
571
|
+
<xsl:value-of select="@href"/>
|
572
|
+
</xsl:message>
|
573
|
+
</xsl:if>
|
574
|
+
<xsl:apply-templates select=" $theFragment[1]" mode="dsdl:go"/>
|
575
|
+
</xsl:for-each>
|
576
|
+
</xsl:when>
|
577
|
+
|
578
|
+
<!-- Case where there is no ID so we include the whole document -->
|
579
|
+
<!-- Experimental addition: include fragments of children -->
|
580
|
+
<xsl:otherwise>
|
581
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
582
|
+
<xsl:variable name="theFragment" select="$theDocument/iso:*" />
|
583
|
+
<xsl:variable name="theContainedFragments" select="$theDocument/*/schold:* | $theDocument/*/xsl:* | $theDocument/*/xhtml:*" />
|
584
|
+
<xsl:if test="not($theDocument)">
|
585
|
+
<xsl:message terminate="no">
|
586
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
587
|
+
<xsl:value-of select="@href"/>
|
588
|
+
</xsl:message>
|
589
|
+
</xsl:if>
|
590
|
+
|
591
|
+
<xsl:if test=" $theFragment/self::schold:schema or $theContainedFragments/self::schold:schema">
|
592
|
+
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
593
|
+
</xsl:if>
|
594
|
+
<xsl:if test="not($theFragment) and not ($theContainedFragments)">
|
595
|
+
<xsl:message terminate="no">
|
596
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
597
|
+
<xsl:value-of select="@href"/>
|
598
|
+
</xsl:message>
|
599
|
+
</xsl:if>
|
600
|
+
<!-- If this were XLST 2, we could use
|
601
|
+
if ($theFragment) then $theFragment else $theContainedFragments
|
602
|
+
here (thanks to KN)
|
603
|
+
-->
|
604
|
+
<xsl:choose>
|
605
|
+
<xsl:when test=" $theFragment ">
|
606
|
+
<xsl:apply-templates select="$theFragment " mode="dsdl:go"/>
|
607
|
+
</xsl:when>
|
608
|
+
<xsl:otherwise>
|
609
|
+
<!-- WARNING! EXPERIMENTAL! Use at your own risk. This may be discontinued! -->
|
610
|
+
<xsl:apply-templates select=" $theContainedFragments " mode="dsdl:go"/>
|
611
|
+
</xsl:otherwise>
|
612
|
+
</xsl:choose>
|
613
|
+
</xsl:otherwise>
|
614
|
+
</xsl:choose>
|
615
|
+
|
616
|
+
</xsl:otherwise>
|
617
|
+
</xsl:choose>
|
618
|
+
|
619
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
620
|
+
</xsl:template>
|
621
|
+
<!-- =========================================================== -->
|
622
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
623
|
+
<!-- Part 5 - DataType Library Language - DTLL -->
|
624
|
+
<!-- Committee Draft Experimental support only -->
|
625
|
+
<!-- The <include> element may well be replaced by XInclude in -->
|
626
|
+
<!-- any final version. -->
|
627
|
+
<!-- =========================================================== -->
|
628
|
+
<xslt:template match="dtll:include" mode="dsdl:go">
|
629
|
+
<!-- Insert subschema -->
|
630
|
+
|
631
|
+
<xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
|
632
|
+
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
|
633
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
634
|
+
<xsl:choose>
|
635
|
+
<xsl:when test="not( $include-dtll = 'true' )">
|
636
|
+
<xslt:copy>
|
637
|
+
<xslt:copy-of select="@*" />
|
638
|
+
<xslt:apply-templates mode="dsdl:go" />
|
639
|
+
</xslt:copy>
|
640
|
+
</xsl:when>
|
641
|
+
<xsl:otherwise>
|
642
|
+
<xsl:choose>
|
643
|
+
|
644
|
+
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
|
645
|
+
<xsl:message>Error: Impossible URL in DTLL include</xsl:message>
|
646
|
+
</xsl:when>
|
647
|
+
|
648
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
649
|
+
<xslt:when test="string-length( $document-uri ) = 0">
|
650
|
+
<xslt:apply-templates mode="dsdl:go"
|
651
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id)
|
652
|
+
| //*[@id= $fragment-id ]"/>
|
653
|
+
</xslt:when>
|
654
|
+
|
655
|
+
<xsl:when test="string-length( $fragment-id ) > 0">
|
656
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
657
|
+
<xsl:if test="not($theDocument)">
|
658
|
+
<xsl:message terminate="no">
|
659
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
660
|
+
<xsl:value-of select="@href"/>
|
661
|
+
</xsl:message>
|
662
|
+
</xsl:if>
|
663
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
664
|
+
<xsl:for-each select="$theDocument" >
|
665
|
+
<xsl:variable name="theFragment" select="$theDocument//*[@xml:id= $fragment-id ]
|
666
|
+
| id( $fragment-id )
|
667
|
+
| $theDocument//*[@id= $fragment-id ]" />
|
668
|
+
<xsl:if test="not($theFragment)">
|
669
|
+
<xsl:message terminate="no">
|
670
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
671
|
+
<xsl:value-of select="@href"/>
|
672
|
+
</xsl:message>
|
673
|
+
</xsl:if>
|
674
|
+
<xsl:apply-templates select=" $theFragment[1]" mode="dsdl:go"/>
|
675
|
+
</xsl:for-each>
|
676
|
+
</xsl:when>
|
677
|
+
|
678
|
+
<xsl:otherwise>
|
679
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
680
|
+
<xsl:variable name="theFragment" select="$theDocument/*" />
|
681
|
+
|
682
|
+
<xsl:if test="not($theDocument)">
|
683
|
+
<xsl:message terminate="no">
|
684
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
685
|
+
<xsl:value-of select="@href"/>
|
686
|
+
</xsl:message>
|
687
|
+
</xsl:if>
|
688
|
+
|
689
|
+
<xsl:if test="not($theFragment)">
|
690
|
+
<xsl:message terminate="no">
|
691
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
692
|
+
<xsl:value-of select="@href"/>
|
693
|
+
</xsl:message>
|
694
|
+
</xsl:if>
|
695
|
+
<xsl:apply-templates select="$theFragment " mode="dsdl:go"/>
|
696
|
+
</xsl:otherwise>
|
697
|
+
</xsl:choose>
|
698
|
+
|
699
|
+
</xsl:otherwise>
|
700
|
+
</xsl:choose>
|
701
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
702
|
+
</xslt:template>
|
703
|
+
|
704
|
+
<!-- =========================================================== -->
|
705
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
706
|
+
<!-- Part 7 - Character Repertoire Description Language - CRDL -->
|
707
|
+
<!-- Final Committee Draft 2008-01-11 Experimental support only -->
|
708
|
+
<!-- =========================================================== -->
|
709
|
+
<xslt:template match="crdl:ref" mode="dsdl:go">
|
710
|
+
<!-- Insert subschema -->
|
711
|
+
|
712
|
+
<xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
|
713
|
+
<xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
|
714
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
715
|
+
<xsl:choose>
|
716
|
+
<xsl:when test="not( $include-crdl = 'true' )">
|
717
|
+
<xslt:copy>
|
718
|
+
<xslt:copy-of select="@*" />
|
719
|
+
<xslt:apply-templates mode="dsdl:go" />
|
720
|
+
</xslt:copy>
|
721
|
+
</xsl:when>
|
722
|
+
<xsl:otherwise>
|
723
|
+
<xsl:choose>
|
724
|
+
|
725
|
+
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
|
726
|
+
<xsl:message>Error: Impossible URL in CRDL include</xsl:message>
|
727
|
+
</xsl:when>
|
728
|
+
|
729
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
730
|
+
<xslt:when test="string-length( $document-uri ) = 0">
|
731
|
+
|
732
|
+
<xslt:apply-templates mode="dsdl:go"
|
733
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id)
|
734
|
+
| //*[@id= $fragment-id ]"/>
|
735
|
+
</xslt:when>
|
736
|
+
|
737
|
+
<xsl:when test="string-length( $fragment-id ) > 0">
|
738
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
739
|
+
<xsl:if test="not($theDocument)">
|
740
|
+
<xsl:message terminate="no">
|
741
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
742
|
+
<xsl:value-of select="@href"/>
|
743
|
+
</xsl:message>
|
744
|
+
</xsl:if>
|
745
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
746
|
+
<xsl:for-each select="$theDocument" >
|
747
|
+
<xsl:variable name="theFragment" select="$theDocument//*[@xml:id= $fragment-id ]
|
748
|
+
| id( $fragment-id )
|
749
|
+
| $theDocument//*[@id= $fragment-id ]" />
|
750
|
+
|
751
|
+
<xsl:if test="not($theFragment)">
|
752
|
+
<xsl:message terminate="no">
|
753
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
754
|
+
<xsl:value-of select="@href"/>
|
755
|
+
</xsl:message>
|
756
|
+
</xsl:if>
|
757
|
+
<xsl:apply-templates select=" $theFragment " mode="dsdl:go"/>
|
758
|
+
</xsl:for-each>
|
759
|
+
</xsl:when>
|
760
|
+
|
761
|
+
<xsl:otherwise>
|
762
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
763
|
+
<xsl:variable name="theFragment" select="$theDocument/*" />
|
764
|
+
|
765
|
+
<xsl:if test="not($theDocument)">
|
766
|
+
<xsl:message terminate="no">
|
767
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
768
|
+
<xsl:value-of select="@href"/>
|
769
|
+
</xsl:message>
|
770
|
+
</xsl:if>
|
771
|
+
<xsl:if test="not($theFragment)">
|
772
|
+
<xsl:message terminate="no">
|
773
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
774
|
+
<xsl:value-of select="@href"/>
|
775
|
+
</xsl:message>
|
776
|
+
</xsl:if>
|
777
|
+
|
778
|
+
<xsl:apply-templates select="$theFragment " mode="dsdl:go"/>
|
779
|
+
</xsl:otherwise>
|
780
|
+
</xsl:choose>
|
781
|
+
|
782
|
+
</xsl:otherwise>
|
783
|
+
</xsl:choose>
|
784
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
785
|
+
</xslt:template>
|
786
|
+
|
787
|
+
|
788
|
+
<!-- =========================================================== -->
|
789
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
790
|
+
<!-- Part 4 - Namespace-based Validation Dispatching Language - NVDL -->
|
791
|
+
<!-- Note: This does not include schemas referenced for -->
|
792
|
+
<!-- validation, it merely handles any simple XIncludes -->
|
793
|
+
<!-- =========================================================== -->
|
794
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
795
|
+
<!-- Part 8 - Document Schema Renaming Language - DSRL -->
|
796
|
+
<!-- Note: Final? Committee Draft Experimental support only -->
|
797
|
+
<!-- =========================================================== -->
|
798
|
+
<!-- XInclude support for id based references only, with 1 level -->
|
799
|
+
<!-- of fallback. -->
|
800
|
+
<!-- =========================================================== -->
|
801
|
+
|
802
|
+
<xslt:template mode="dsdl:go"
|
803
|
+
match="xi:include[@href][not(@parseType) or @parseType ='xml']">
|
804
|
+
<!-- Simple inclusions only here -->
|
805
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
806
|
+
<xsl:choose>
|
807
|
+
<xsl:when test="not( $include-xinclude = 'true' )">
|
808
|
+
<xslt:copy>
|
809
|
+
<xslt:copy-of select="@*" />
|
810
|
+
<xslt:apply-templates mode="dsdl:go" />
|
811
|
+
</xslt:copy>
|
812
|
+
</xsl:when>
|
813
|
+
<xsl:otherwise>
|
814
|
+
<xsl:choose>
|
815
|
+
|
816
|
+
<xsl:when test="contains( @href, '#')">
|
817
|
+
<xsl:message terminate="yes">Fatal error: Xinclude href contains
|
818
|
+
fragment identifier #</xsl:message>
|
819
|
+
</xsl:when>
|
820
|
+
|
821
|
+
|
822
|
+
<xsl:when test="contains( @xpointer, '(')">
|
823
|
+
<xsl:message terminate="yes">Fatal error: Sorry, this software
|
824
|
+
only supports simple ids in XInclude xpointers</xsl:message>
|
825
|
+
</xsl:when>
|
826
|
+
|
827
|
+
<xsl:when test="string-length( @href ) = 0 and string-length( @xpointer ) = 0" >
|
828
|
+
|
829
|
+
<xsl:message terminate="yes">Fatal Error: Impossible URL in XInclude include</xsl:message>
|
830
|
+
</xsl:when>
|
831
|
+
|
832
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
833
|
+
<xslt:when test="string-length( @href ) = 0">
|
834
|
+
|
835
|
+
<xslt:apply-templates mode="dsdl:go"
|
836
|
+
select="//*[@xml:id= current()/@xpointer ] | id( @xpointer)
|
837
|
+
| //*[@id= current()/@xpointer ]"/>
|
838
|
+
</xslt:when>
|
839
|
+
|
840
|
+
<xsl:when test="string-length( @xpointer ) > 0">
|
841
|
+
<xsl:variable name="theDocument" select="document( @href,/ )" />
|
842
|
+
<xsl:variable name="theFragment" select="$theDocument//*[@xml:id= current()/@xpointer ]
|
843
|
+
|
844
|
+
| $theDocument//*[@id= current()/@xpointer ]" />
|
845
|
+
<!-- removed
|
846
|
+
| $theDocument/id( @xpointer)
|
847
|
+
because it requires rebasing in XSLT1 and that would mess up the use of current()
|
848
|
+
-->
|
849
|
+
|
850
|
+
|
851
|
+
<!-- Allow one level of fallback, to another XInclude -->
|
852
|
+
<xsl:if test="not($theDocument)">
|
853
|
+
<xsl:choose>
|
854
|
+
<xsl:when test="xi:fallback">
|
855
|
+
<xsl:variable name="theDocument" select="document( xi:fallback[1]/xi:include[not(@parseType)
|
856
|
+
or @parseType='xml']/@href,/ )" />
|
857
|
+
<xsl:variable name="theFragment" select="$theDocument//*[@xml:id= current()/xi:fallback[1]/xi:include/@xpointer ]
|
858
|
+
| $theDocument//*[@id= current()/xi:fallback[1]/xi:include/@xpointer ]" />
|
859
|
+
<!-- removed
|
860
|
+
| $theDocument/id( xi:fallback[1]/xi:include/@xpointer)
|
861
|
+
because it id() would need rebasing in XSLT1 and that would mess up use of current()
|
862
|
+
-->
|
863
|
+
|
864
|
+
<xsl:if test="not($theDocument)">
|
865
|
+
|
866
|
+
<xsl:message terminate="no">
|
867
|
+
<xsl:text>Unable to open referenced included file and fallback
|
868
|
+
file: </xsl:text>
|
869
|
+
<xsl:value-of select="@href"/>
|
870
|
+
</xsl:message>
|
871
|
+
</xsl:if>
|
872
|
+
</xsl:when>
|
873
|
+
<xsl:otherwise>
|
874
|
+
<xsl:message terminate="no">
|
875
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
876
|
+
<xsl:value-of select="@href"/>
|
877
|
+
</xsl:message>
|
878
|
+
</xsl:otherwise>
|
879
|
+
</xsl:choose>
|
880
|
+
</xsl:if>
|
881
|
+
<xsl:apply-templates select=" $theFragment" mode="dsdl:go"/>
|
882
|
+
</xsl:when>
|
883
|
+
|
884
|
+
<!-- Document but no fragment specified -->
|
885
|
+
<xsl:otherwise>
|
886
|
+
<xsl:variable name="theDocument" select="document( @href,/ )" />
|
887
|
+
<xsl:variable name="theFragment" select="$theDocument/*" />
|
888
|
+
|
889
|
+
<xsl:if test="not($theDocument)">
|
890
|
+
<xsl:message terminate="no">
|
891
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
892
|
+
<xsl:value-of select="@href"/>
|
893
|
+
</xsl:message>
|
894
|
+
</xsl:if>
|
895
|
+
|
896
|
+
<xsl:apply-templates select="$theFragment " mode="dsdl:go"/>
|
897
|
+
</xsl:otherwise>
|
898
|
+
</xsl:choose>
|
899
|
+
|
900
|
+
</xsl:otherwise>
|
901
|
+
</xsl:choose>
|
902
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@href"/></xsl:processing-instruction>
|
903
|
+
</xslt:template>
|
904
|
+
|
905
|
+
<!-- =========================================================== -->
|
906
|
+
<!-- W3C XLink 1.1 embedded simple links -->
|
907
|
+
<!-- =========================================================== -->
|
908
|
+
<xslt:template match="*[@xlink:href][not(parent::*[@xlink:type='complex'])]
|
909
|
+
[not(@xlink:type) or (@xlink:type='simple')]
|
910
|
+
[@xlink:show='embed']
|
911
|
+
[not(@xlink:actuate) or (@xlink:actuate='onLoad')]"
|
912
|
+
mode="dsdl:go" priority="1">
|
913
|
+
|
914
|
+
<xsl:variable name="document-uri" select="substring-before(concat(@xlink:href,'#'), '#')"/>
|
915
|
+
<xsl:variable name="fragment-id" select="substring-after(@xlink:href, '#')"/>
|
916
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@xlink:href"/></xsl:processing-instruction>
|
917
|
+
<xsl:choose>
|
918
|
+
<xsl:when test="not( $include-xlink = 'true' )">
|
919
|
+
<xslt:copy>
|
920
|
+
<xslt:copy-of select="@*" />
|
921
|
+
<xslt:apply-templates mode="dsdl:go" />
|
922
|
+
</xslt:copy>
|
923
|
+
</xsl:when>
|
924
|
+
<xsl:otherwise>
|
925
|
+
<xsl:choose>
|
926
|
+
|
927
|
+
<xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
|
928
|
+
<xsl:message>Error: Impossible URL in XLink embedding link</xsl:message>
|
929
|
+
</xsl:when>
|
930
|
+
|
931
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
932
|
+
<xslt:when test="string-length( $document-uri ) = 0">
|
933
|
+
<xslt:apply-templates mode="dsdl:go"
|
934
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id)
|
935
|
+
| //*[@id= $fragment-id ]"/>
|
936
|
+
</xslt:when>
|
937
|
+
|
938
|
+
<xsl:when test="string-length( $fragment-id ) > 0">
|
939
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
940
|
+
<xsl:if test="not($theDocument)">
|
941
|
+
<xsl:message terminate="no">
|
942
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
943
|
+
<xsl:value-of select="@xlink:href"/>
|
944
|
+
</xsl:message>
|
945
|
+
</xsl:if>
|
946
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
947
|
+
<xsl:for-each select="$theDocument" >
|
948
|
+
<xsl:variable name="theFragment" select="$theDocument//*[@xml:id= $fragment-id ]
|
949
|
+
| id( $fragment-id )
|
950
|
+
| $theDocument//*[@id= $fragment-id ]" />
|
951
|
+
<xsl:if test="not($theFragment)">
|
952
|
+
<xsl:message terminate="no">
|
953
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
954
|
+
<xsl:value-of select="@xlink:href"/>
|
955
|
+
</xsl:message>
|
956
|
+
</xsl:if>
|
957
|
+
<xsl:apply-templates select=" $theFragment[1]" mode="dsdl:go"/>
|
958
|
+
</xsl:for-each>
|
959
|
+
</xsl:when>
|
960
|
+
|
961
|
+
<xsl:otherwise>
|
962
|
+
<xsl:variable name="theDocument" select="document( $document-uri,/ )" />
|
963
|
+
<xsl:variable name="theFragment" select="$theDocument/*" />
|
964
|
+
|
965
|
+
<xsl:if test="not($theDocument)">
|
966
|
+
<xsl:message terminate="no">
|
967
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
968
|
+
<xsl:value-of select="@xlink:href"/>
|
969
|
+
</xsl:message>
|
970
|
+
</xsl:if>
|
971
|
+
|
972
|
+
<xsl:if test="not($theFragment)">
|
973
|
+
<xsl:message terminate="no">
|
974
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
975
|
+
<xsl:value-of select="@xlink:href"/>
|
976
|
+
</xsl:message>
|
977
|
+
</xsl:if>
|
978
|
+
<xsl:apply-templates select="$theFragment " mode="dsdl:go"/>
|
979
|
+
</xsl:otherwise>
|
980
|
+
</xsl:choose>
|
981
|
+
|
982
|
+
</xsl:otherwise>
|
983
|
+
</xsl:choose>
|
984
|
+
|
985
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START"> <xsl:value-of select="@xlink:href"/></xsl:processing-instruction>
|
986
|
+
</xslt:template>
|
987
|
+
|
988
|
+
|
989
|
+
</xslt:stylesheet>
|