schematron 0.1.2 → 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.
- data/.semver +5 -0
- data/README.md +4 -4
- data/bin/stron +21 -14
- data/{iso_impl → iso-schematron-xslt1}/iso_abstract_expand.xsl +2 -1
- data/iso-schematron-xslt1/iso_dsdl_include.xsl +1160 -0
- data/iso-schematron-xslt1/iso_schematron_message.xsl +55 -0
- data/{iso_impl → iso-schematron-xslt1}/iso_schematron_skeleton_for_xslt1.xsl +108 -36
- data/{iso_impl/iso_svrl.xsl → iso-schematron-xslt1/iso_svrl_for_xslt1.xsl} +16 -11
- data/iso-schematron-xslt1/readme.txt +83 -0
- data/lib/schematron.rb +3 -3
- data/schematron.gemspec +8 -27
- metadata +19 -9
- data/Rakefile +0 -14
- data/iso_impl/iso_dsdl_include.xsl +0 -989
- data/iso_impl/iso_schematron_skeleton_for_saxon.xsl +0 -1884
- data/iso_impl/iso_schematron_text.xsl +0 -126
@@ -0,0 +1,55 @@
|
|
1
|
+
<?xml version="1.0" ?><?xar XSLT?>
|
2
|
+
<!-- Implmentation for the Schematron XML Schema Language.
|
3
|
+
http://www.ascc.net/xml/resource/schematron/schematron.html
|
4
|
+
|
5
|
+
Copyright (c) 2000,2001 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
|
6
|
+
|
7
|
+
This software is provided 'as-is', without any express or implied warranty.
|
8
|
+
In no event will the authors be held liable for any damages arising from
|
9
|
+
the use of this software.
|
10
|
+
|
11
|
+
Permission is granted to anyone to use this software for any purpose,
|
12
|
+
including commercial applications, and to alter it and redistribute it freely,
|
13
|
+
subject to the following restrictions:
|
14
|
+
|
15
|
+
1. The origin of this software must not be misrepresented; you must not claim
|
16
|
+
that you wrote the original software. If you use this software in a product,
|
17
|
+
an acknowledgment in the product documentation would be appreciated but is
|
18
|
+
not required.
|
19
|
+
|
20
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
21
|
+
misrepresented as being the original software.
|
22
|
+
|
23
|
+
3. This notice may not be removed or altered from any source distribution.
|
24
|
+
-->
|
25
|
+
|
26
|
+
<!-- Schematron message -->
|
27
|
+
|
28
|
+
<xsl:stylesheet
|
29
|
+
version="1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias">
|
32
|
+
|
33
|
+
<xsl:import href="iso_schematron_skeleton_for_xslt1.xsl"/>
|
34
|
+
|
35
|
+
<xsl:template name="process-prolog">
|
36
|
+
<axsl:output method="text" />
|
37
|
+
</xsl:template>
|
38
|
+
|
39
|
+
<!-- use default rule for process-root: copy contens / ignore title -->
|
40
|
+
<!-- use default rule for process-pattern: ignore name and see -->
|
41
|
+
<!-- use default rule for process-name: output name -->
|
42
|
+
<!-- use default rule for process-assert and process-report:
|
43
|
+
call process-message -->
|
44
|
+
|
45
|
+
<xsl:template name="process-message">
|
46
|
+
<xsl:param name="pattern" />
|
47
|
+
<xsl:param name="role" />
|
48
|
+
<axsl:message>
|
49
|
+
<xsl:apply-templates mode="text"
|
50
|
+
/> (<xsl:value-of select="$pattern" />
|
51
|
+
<xsl:if test="$role"> / <xsl:value-of select="$role" />
|
52
|
+
</xsl:if>)</axsl:message>
|
53
|
+
</xsl:template>
|
54
|
+
|
55
|
+
</xsl:stylesheet>
|
@@ -172,8 +172,24 @@
|
|
172
172
|
|
173
173
|
3. This notice may not be removed or altered from any source distribution.
|
174
174
|
-->
|
175
|
-
<!--
|
176
|
-
|
175
|
+
<!--
|
176
|
+
NOTE: Compared to the iso_schematron_skeleton_for_saxon.xsl code, this version is currently missing
|
177
|
+
1) localization
|
178
|
+
2) properties
|
179
|
+
3) pattern/@documents
|
180
|
+
|
181
|
+
VERSION INFORMATION
|
182
|
+
|
183
|
+
2010-01-24 RJ
|
184
|
+
* Allow let elements to have direct content instead of @value
|
185
|
+
2009-02-25 RJ
|
186
|
+
* Fix up variable names so none are used twice in same template
|
187
|
+
* Tested on SAXON 9, Xalan 2.7.1. Partly tested MSXML.
|
188
|
+
2008-09-19 RJ
|
189
|
+
* Add mode schematron-select-full-path and param full-path-notation
|
190
|
+
|
191
|
+
2008-08-11
|
192
|
+
* TT report/@flag was missing
|
177
193
|
2008-08-06
|
178
194
|
* TT Top-level lets need to be implemented using xsl:param not xsl:variable
|
179
195
|
* TT xsl:param/@select must have XPath or not be specified
|
@@ -468,7 +484,14 @@
|
|
468
484
|
<!-- e.g. saxon file.xml file.xsl "sch.exslt.imports=.../string.xsl;.../math.xsl" -->
|
469
485
|
<xsl:param name="sch.exslt.imports"/>
|
470
486
|
|
471
|
-
|
487
|
+
<!-- Set the language code for messages -->
|
488
|
+
<xsl:param name="langCode">default</xsl:param>
|
489
|
+
|
490
|
+
<xsl:param name="debug">false</xsl:param>
|
491
|
+
|
492
|
+
|
493
|
+
<!-- Set the default for schematron-select-full-path, i.e. the notation for svrl's @location-->
|
494
|
+
<xsl:param name="full-path-notation">1</xsl:param>
|
472
495
|
|
473
496
|
<!-- Simple namespace check -->
|
474
497
|
<xsl:template match="/">
|
@@ -591,7 +614,33 @@
|
|
591
614
|
</xsl:if>
|
592
615
|
</xsl:template>
|
593
616
|
|
594
|
-
<xsl:template name="generate-default-rules">
|
617
|
+
<xsl:template name="generate-default-rules">
|
618
|
+
<xsl:text> </xsl:text>
|
619
|
+
<xsl:comment>MODE: SCHEMATRON-SELECT-FULL-PATH</xsl:comment><xsl:text> </xsl:text>
|
620
|
+
<xsl:comment>This mode can be used to generate an ugly though full XPath for locators</xsl:comment><xsl:text> </xsl:text>
|
621
|
+
<axsl:template match="*" mode="schematron-select-full-path">
|
622
|
+
<xsl:choose>
|
623
|
+
<xsl:when test=" $full-path-notation = '1' ">
|
624
|
+
<!-- Use for computers, but rather unreadable for humans -->
|
625
|
+
<axsl:apply-templates select="." mode="schematron-get-full-path"/>
|
626
|
+
</xsl:when>
|
627
|
+
<xsl:when test=" $full-path-notation = '2' ">
|
628
|
+
<!-- Use for humans, but no good for paths unless namespaces are known out-of-band -->
|
629
|
+
<axsl:apply-templates select="." mode="schematron-get-full-path-2"/>
|
630
|
+
</xsl:when>
|
631
|
+
<xsl:when test=" $full-path-notation = '3' ">
|
632
|
+
<!-- Obsolescent. Use for humans, but no good for paths unless namespaces are known out-of-band -->
|
633
|
+
<axsl:apply-templates select="." mode="schematron-get-full-path-3"/>
|
634
|
+
</xsl:when>
|
635
|
+
|
636
|
+
<xsl:otherwise >
|
637
|
+
<!-- Use for computers, but rather unreadable for humans -->
|
638
|
+
<axsl:apply-templates select="." mode="schematron-get-full-path"/>
|
639
|
+
</xsl:otherwise>
|
640
|
+
</xsl:choose>
|
641
|
+
</axsl:template>
|
642
|
+
|
643
|
+
|
595
644
|
<xsl:text> </xsl:text>
|
596
645
|
<xsl:comment>MODE: SCHEMATRON-FULL-PATH</xsl:comment><xsl:text> </xsl:text>
|
597
646
|
<xsl:comment>This mode can be used to generate an ugly though full XPath for locators</xsl:comment><xsl:text> </xsl:text>
|
@@ -604,10 +653,10 @@
|
|
604
653
|
<axsl:choose>
|
605
654
|
<axsl:when test="namespace-uri()=''">
|
606
655
|
<axsl:value-of select="name()"/>
|
607
|
-
<axsl:variable name="
|
656
|
+
<axsl:variable name="p_1" select="1+
|
608
657
|
count(preceding-sibling::*[name()=name(current())])" />
|
609
|
-
<axsl:if test="$
|
610
|
-
<xsl:text/>[<axsl:value-of select="$
|
658
|
+
<axsl:if test="$p_1>1 or following-sibling::*[name()=name(current())]">
|
659
|
+
<xsl:text/>[<axsl:value-of select="$p_1"/>]<xsl:text/>
|
611
660
|
</axsl:if>
|
612
661
|
</axsl:when>
|
613
662
|
<axsl:otherwise>
|
@@ -615,10 +664,10 @@
|
|
615
664
|
<axsl:value-of select="local-name()"/><axsl:text>' and namespace-uri()='</axsl:text>
|
616
665
|
<axsl:value-of select="namespace-uri()"/>
|
617
666
|
<axsl:text>']</axsl:text>
|
618
|
-
<axsl:variable name="
|
667
|
+
<axsl:variable name="p_2" select="1+
|
619
668
|
count(preceding-sibling::*[local-name()=local-name(current())])" />
|
620
|
-
<axsl:if test="$
|
621
|
-
<xsl:text/>[<axsl:value-of select="$
|
669
|
+
<axsl:if test="$p_2>1 or following-sibling::*[local-name()=local-name(current())]">
|
670
|
+
<xsl:text/>[<axsl:value-of select="$p_2"/>]<xsl:text/>
|
622
671
|
</axsl:if>
|
623
672
|
</axsl:otherwise>
|
624
673
|
</axsl:choose>
|
@@ -868,7 +917,8 @@
|
|
868
917
|
<xsl:call-template name="process-report">
|
869
918
|
<xsl:with-param name="test" select="normalize-space(@test)" />
|
870
919
|
<xsl:with-param name="diagnostics" select="@diagnostics"/>
|
871
|
-
|
920
|
+
<xsl:with-param name="flag" select="@flag"/>
|
921
|
+
|
872
922
|
<!-- "Rich" properties -->
|
873
923
|
<xsl:with-param name="fpi" select="@fpi"/>
|
874
924
|
<xsl:with-param name="icon" select="@icon"/>
|
@@ -1019,22 +1069,22 @@
|
|
1019
1069
|
</xsl:when>
|
1020
1070
|
|
1021
1071
|
<xsl:when test="string-length( $fragment-id ) > 0">
|
1022
|
-
<xsl:variable name="
|
1023
|
-
<xsl:variable name="
|
1024
|
-
<xsl:if test=" $
|
1072
|
+
<xsl:variable name="theDocument_1" select="document( $document-uri,/ )" />
|
1073
|
+
<xsl:variable name="theFragment_1" select="$theDocument_1//iso:*[@id= $fragment-id ]" />
|
1074
|
+
<xsl:if test=" $theFragment_1/self::iso:schema ">
|
1025
1075
|
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
1026
1076
|
</xsl:if>
|
1027
|
-
<xsl:apply-templates select=" $
|
1077
|
+
<xsl:apply-templates select=" $theFragment_1"/>
|
1028
1078
|
</xsl:when>
|
1029
1079
|
|
1030
1080
|
<xsl:otherwise>
|
1031
|
-
<xsl:variable name="
|
1032
|
-
<xsl:variable name="
|
1033
|
-
<xsl:variable name="theContainedFragments" select="$
|
1034
|
-
<xsl:if test=" $
|
1081
|
+
<xsl:variable name="theDocument_2" select="document( $document-uri,/ )" />
|
1082
|
+
<xsl:variable name="theFragment_2" select="$theDocument_2/iso:*" />
|
1083
|
+
<xsl:variable name="theContainedFragments" select="$theDocument_2/*/iso:*" />
|
1084
|
+
<xsl:if test=" $theFragment_2/self::iso:schema or $theContainedFragments/self::iso:schema">
|
1035
1085
|
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
1036
1086
|
</xsl:if>
|
1037
|
-
<xsl:apply-templates select="$
|
1087
|
+
<xsl:apply-templates select="$theFragment_2 | $theContainedFragments "/>
|
1038
1088
|
</xsl:otherwise>
|
1039
1089
|
</xsl:choose>
|
1040
1090
|
</xsl:template>
|
@@ -1051,24 +1101,24 @@
|
|
1051
1101
|
</xsl:when>
|
1052
1102
|
|
1053
1103
|
<xsl:when test="string-length( $fragment-id ) > 0">
|
1054
|
-
<xsl:variable name="
|
1055
|
-
<xsl:variable name="
|
1056
|
-
<xsl:if test=" $
|
1104
|
+
<xsl:variable name="theDocument_1" select="document( $document-uri,/ )" />
|
1105
|
+
<xsl:variable name="theFragment_1" select="$theDocument_1//iso:*[@id= $fragment-id ]" />
|
1106
|
+
<xsl:if test=" $theFragment_1/self::iso:schema ">
|
1057
1107
|
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
1058
1108
|
</xsl:if>
|
1059
|
-
<xsl:apply-templates select=" $
|
1109
|
+
<xsl:apply-templates select=" $theFragment_1" mode="do-all-patterns"/>
|
1060
1110
|
</xsl:when>
|
1061
1111
|
|
1062
1112
|
<xsl:otherwise>
|
1063
1113
|
<!-- Import the top-level element if it is in schematron namespace,
|
1064
1114
|
or its children otherwise, to allow a simple containment mechanism. -->
|
1065
|
-
<xsl:variable name="
|
1066
|
-
<xsl:variable name="
|
1067
|
-
<xsl:variable name="theContainedFragments" select="$
|
1068
|
-
<xsl:if test=" $
|
1115
|
+
<xsl:variable name="theDocument_2" select="document( $document-uri,/ )" />
|
1116
|
+
<xsl:variable name="theFragment_2" select="$theDocument_2/iso:*" />
|
1117
|
+
<xsl:variable name="theContainedFragments" select="$theDocument_2/*/iso:*" />
|
1118
|
+
<xsl:if test=" $theFragment_2/self::iso:schema or $theContainedFragments/self::iso:schema">
|
1069
1119
|
<xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
|
1070
1120
|
</xsl:if>
|
1071
|
-
<xsl:apply-templates select="$
|
1121
|
+
<xsl:apply-templates select="$theFragment_2 | $theContainedFragments "
|
1072
1122
|
mode="do-all-patterns" />
|
1073
1123
|
</xsl:otherwise>
|
1074
1124
|
</xsl:choose>
|
@@ -1080,19 +1130,41 @@
|
|
1080
1130
|
<xsl:message>Warning: Variables should not be used with the "xpath" query language binding.</xsl:message>
|
1081
1131
|
</xsl:if>
|
1082
1132
|
|
1083
|
-
<!-- lets at the top-level are implemented as parameters -->
|
1133
|
+
<!-- lets at the top-level are implemented as parameters unless they have contents -->
|
1084
1134
|
|
1085
1135
|
<xsl:choose>
|
1136
|
+
<!-- TODO: what about top-level lets that include data? -->
|
1086
1137
|
<xsl:when test="parent::iso:schema">
|
1087
1138
|
<!-- it is an error to have an empty param/@select because an XPath is expected -->
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1139
|
+
<!-- So why is the select="{@value}" still there? because the let always has a value! -->
|
1140
|
+
<!-- TODO: remove spurious let. -->
|
1141
|
+
<xsl:choose>
|
1142
|
+
<xsl:when test="@value">
|
1143
|
+
<axsl:param name="{@name}" select="{@value}">
|
1144
|
+
<xsl:if test="string-length(@value) > 0">
|
1145
|
+
<xsl:attribute name="select"><xsl:value-of select="@value"/></xsl:attribute>
|
1146
|
+
</xsl:if>
|
1147
|
+
</axsl:param>
|
1148
|
+
</xsl:when>
|
1149
|
+
<xsl:otherwise>
|
1150
|
+
<axsl:variable name="{@name}" >
|
1151
|
+
<xsl:copy-of select="child::node()" />
|
1152
|
+
</axsl:variable>
|
1153
|
+
</xsl:otherwise>
|
1154
|
+
</xsl:choose>
|
1093
1155
|
</xsl:when>
|
1094
1156
|
<xsl:otherwise>
|
1095
|
-
|
1157
|
+
<xsl:choose>
|
1158
|
+
<xsl:when test="@value">
|
1159
|
+
<axsl:variable name="{@name}" select="{@value}"/>
|
1160
|
+
</xsl:when>
|
1161
|
+
<xsl:otherwise>
|
1162
|
+
<axsl:variable name="{@name}" >
|
1163
|
+
<xsl:copy-of select="child::node()" />
|
1164
|
+
</axsl:variable>
|
1165
|
+
</xsl:otherwise>
|
1166
|
+
</xsl:choose>
|
1167
|
+
|
1096
1168
|
</xsl:otherwise>
|
1097
1169
|
</xsl:choose>
|
1098
1170
|
|
@@ -29,7 +29,9 @@
|
|
29
29
|
validate with schemas from either namespace.
|
30
30
|
|
31
31
|
|
32
|
-
History:
|
32
|
+
History:
|
33
|
+
2009-03-18
|
34
|
+
* Fix atrribute with space "see " which generates wrong name in some processors
|
33
35
|
2008-08-11
|
34
36
|
* RJ Fix attribute/@select which saxon allows in XSLT 1
|
35
37
|
2008-08-07
|
@@ -113,7 +115,7 @@
|
|
113
115
|
|
114
116
|
<!-- The command-line parameters are:
|
115
117
|
phase NMTOKEN | "#ALL" (default) Select the phase for validation
|
116
|
-
allow-foreign "true" | "false" (default) Pass non-Schematron elements to the generated stylesheet
|
118
|
+
allow-foreign "true" | "false" (default) Pass non-Schematron elements and rich markup to the generated stylesheet
|
117
119
|
diagnose= true | false|yes|no Add the diagnostics to the assertion test in reports (yes|no are obsolete)
|
118
120
|
generate-paths=true|false|yes|no generate the @location attribute with XPaths (yes|no are obsolete)
|
119
121
|
sch.exslt.imports semi-colon delimited string of filenames for some EXSLT implementations
|
@@ -133,12 +135,15 @@
|
|
133
135
|
>
|
134
136
|
|
135
137
|
<!-- Select the import statement and adjust the path as
|
136
|
-
necessary for your system.
|
137
|
-
|
138
|
-
|
138
|
+
necessary for your system.
|
139
|
+
If not XSLT2 then also remove svrl:active-pattern/@document="{document-uri()}" from process-pattern()
|
140
|
+
-->
|
139
141
|
<!--
|
140
142
|
<xsl:import href="iso_schematron_skeleton_for_saxon.xsl"/>
|
141
|
-
|
143
|
+
-->
|
144
|
+
|
145
|
+
<xsl:import href="iso_schematron_skeleton_for_xslt1.xsl"/>
|
146
|
+
<!--
|
142
147
|
<xsl:import href="iso_schematron_skeleton.xsl"/>
|
143
148
|
<xsl:import href="skeleton1-5.xsl"/>
|
144
149
|
<xsl:import href="skeleton1-6.xsl"/>
|
@@ -474,7 +479,7 @@
|
|
474
479
|
<xsl:param name="lang" />
|
475
480
|
<xsl:param name="see" />
|
476
481
|
<xsl:param name="space" />
|
477
|
-
<svrl:active-pattern >
|
482
|
+
<svrl:active-pattern >
|
478
483
|
<xsl:if test=" string( $id )">
|
479
484
|
<axsl:attribute name="id">
|
480
485
|
<xsl:value-of select=" $id " />
|
@@ -537,17 +542,17 @@
|
|
537
542
|
<xsl:if test=" $allow-foreign = 'true'">
|
538
543
|
<xsl:if test="string($fpi)">
|
539
544
|
<axsl:attribute name="fpi">
|
540
|
-
<xsl:value-of select="$fpi
|
545
|
+
<xsl:value-of select="$fpi"/>
|
541
546
|
</axsl:attribute>
|
542
547
|
</xsl:if>
|
543
548
|
<xsl:if test="string($icon)">
|
544
549
|
<axsl:attribute name="icon">
|
545
|
-
<xsl:value-of select="$icon
|
550
|
+
<xsl:value-of select="$icon"/>
|
546
551
|
</axsl:attribute>
|
547
552
|
</xsl:if>
|
548
553
|
<xsl:if test="string($see)">
|
549
|
-
<axsl:attribute name="see
|
550
|
-
<xsl:value-of select="$see
|
554
|
+
<axsl:attribute name="see">
|
555
|
+
<xsl:value-of select="$see"/>
|
551
556
|
</axsl:attribute>
|
552
557
|
</xsl:if>
|
553
558
|
</xsl:if>
|
@@ -0,0 +1,83 @@
|
|
1
|
+
ISO SCHEMATRON 2010
|
2
|
+
|
3
|
+
XSLT implementation by Rick Jelliffe with assistance from members of Schematron-love-in maillist.
|
4
|
+
|
5
|
+
2010-01-25
|
6
|
+
|
7
|
+
Two distributions are available. One is for XSLT1 engines.
|
8
|
+
The other is for XSLT2 engines, such as SAXON 9.
|
9
|
+
|
10
|
+
|
11
|
+
This version of Schematron splits the process into a pipeline of several different XSLT stages.
|
12
|
+
|
13
|
+
1) First, preprocess your Schematron schema with iso_dsdl_include.xsl.
|
14
|
+
This is a macro processor to assemble the schema from various parts.
|
15
|
+
If your schema is not in separate parts, you can skip this stage.
|
16
|
+
|
17
|
+
2) Second, preprocess the output from stage 1 with iso_abstract_expand.xsl.
|
18
|
+
This is a macro processor to convert abstract patterns to real patterns.
|
19
|
+
If your schema does not use abstract patterns, you can skip this
|
20
|
+
stage.
|
21
|
+
|
22
|
+
3) Third, compile the Schematron schema into an XSLT script.
|
23
|
+
This will typically use iso_svrl_for_xslt1.xsl or iso_svrl_for_xslt2.xsl
|
24
|
+
(which in turn invoke iso_schematron_skeleton_for_xslt1.xsl or iso_schematron_skeleton_for_saxon.xsl)
|
25
|
+
However, other "meta-styleseets" are also in common use; the principle of operation is the same.
|
26
|
+
If your schema uses Schematron phases, supply these as command line/invocation parameters
|
27
|
+
to this process.
|
28
|
+
|
29
|
+
4) Fourth, run the script generated by stage 3 against the document being validated.
|
30
|
+
If you are using the SVRL script, then the output of validation will be an XML document.
|
31
|
+
If your schema uses Schematron parameters, supply these as command line/invocation parameters
|
32
|
+
to this process.
|
33
|
+
|
34
|
+
|
35
|
+
The XSLT2 distribution also features several next generation features,
|
36
|
+
such as validating multiple documents. See the source code for details.
|
37
|
+
|
38
|
+
Schematron assertions can be written in any language, of course; the file
|
39
|
+
sch-messages-en.xhtml contains the diagnostics messages from the XSLT2 skeleton
|
40
|
+
in English, and this can be used as template to localize the skeleton's
|
41
|
+
error messages. Note that typically programming errors in Schematron are XPath
|
42
|
+
errors, which requires localized messages from the XSLT engine.
|
43
|
+
|
44
|
+
ANT
|
45
|
+
---
|
46
|
+
To give an example of how to process a document, here is a sample ANT task.
|
47
|
+
|
48
|
+
<target name="schematron-compile-test" >
|
49
|
+
|
50
|
+
<!-- expand inclusions -->
|
51
|
+
<xslt basedir="test/schematron"
|
52
|
+
style="iso_dsdl_include.xsl" in="test.sch" out="test1.sch">
|
53
|
+
<classpath>
|
54
|
+
<pathelement location="${lib.dir}/saxon9.jar"/>
|
55
|
+
</classpath>
|
56
|
+
</xslt>
|
57
|
+
|
58
|
+
<!-- expand abstract patterns -->
|
59
|
+
<xslt basedir="test/schematron"
|
60
|
+
style="iso_abstract_expand.xsl" in="test1.sch" out="test2.sch">
|
61
|
+
<classpath>
|
62
|
+
<pathelement location="${lib.dir}/saxon9.jar"/>
|
63
|
+
</classpath>
|
64
|
+
</xslt>
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
<!-- compile it -->
|
69
|
+
<xslt basedir="test/schematron"
|
70
|
+
style="iso_svrl_for_xslt2.xsl" in="test2.sch" out="test.xsl">
|
71
|
+
<classpath>
|
72
|
+
<pathelement location="${lib.dir}/saxon9.jar"/>
|
73
|
+
</classpath>
|
74
|
+
</xslt>
|
75
|
+
|
76
|
+
<!-- validate -->
|
77
|
+
<xslt basedir="test/schematron"
|
78
|
+
style="test.xsl" in="instance.xml" out="instance.svrlt">
|
79
|
+
<classpath>
|
80
|
+
<pathelement location="${lib.dir}/saxon9.jar"/>
|
81
|
+
</classpath>
|
82
|
+
</xslt>
|
83
|
+
</target>
|
data/lib/schematron.rb
CHANGED
@@ -7,12 +7,12 @@ module Schematron
|
|
7
7
|
include LibXSLT
|
8
8
|
|
9
9
|
# The location of the ISO schematron implemtation lives
|
10
|
-
ISO_IMPL_DIR = File.join File.dirname(__FILE__), "..", '
|
10
|
+
ISO_IMPL_DIR = File.join File.dirname(__FILE__), "..", 'iso-schematron-xslt1'
|
11
11
|
|
12
12
|
# The file names of the compilation stages
|
13
13
|
ISO_FILES = [ 'iso_dsdl_include.xsl',
|
14
14
|
'iso_abstract_expand.xsl',
|
15
|
-
'
|
15
|
+
'iso_svrl_for_xslt1.xsl' ]
|
16
16
|
|
17
17
|
# Namespace prefix declarations for use in XPaths
|
18
18
|
NS_PREFIXES = {
|
@@ -27,7 +27,7 @@ module Schematron
|
|
27
27
|
xforms = ISO_FILES.map do |file|
|
28
28
|
|
29
29
|
Dir.chdir(ISO_IMPL_DIR) do
|
30
|
-
doc = XML::Document.
|
30
|
+
doc = open(file) { |io| XML::Document.string io.read }
|
31
31
|
LibXSLT::XSLT::Stylesheet.new doc
|
32
32
|
end
|
33
33
|
|
data/schematron.gemspec
CHANGED
@@ -1,38 +1,19 @@
|
|
1
|
+
require 'semver'
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
4
|
spec.name = "schematron"
|
3
|
-
spec.version =
|
5
|
+
spec.version = SemVer.find.format '%M.%m.%p'
|
4
6
|
spec.summary = "ISO Schematron Validation"
|
5
7
|
spec.email = "flazzarino@gmail.com"
|
6
8
|
spec.homepage = 'http://github.com/flazz/schematron'
|
7
9
|
spec.authors = ["Francesco Lazzarino"]
|
8
|
-
#spec.rubyforge_project = 'schematron'
|
9
|
-
|
10
10
|
spec.executables << 'stron'
|
11
11
|
|
12
|
-
spec.files = ["
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
"iso_impl/iso_schematron_skeleton_for_saxon.xsl",
|
18
|
-
"iso_impl/iso_schematron_skeleton_for_xslt1.xsl",
|
19
|
-
"iso_impl/iso_schematron_text.xsl",
|
20
|
-
"iso_impl/iso_svrl.xsl",
|
21
|
-
"spec/command_spec.rb",
|
22
|
-
"spec/feature_requests_spec.rb",
|
23
|
-
"spec/instances",
|
24
|
-
"spec/instances/daitss-sip",
|
25
|
-
"spec/instances/daitss-sip/Example1.xml",
|
26
|
-
"spec/instances/daitss-sip/Example2.xml",
|
27
|
-
"spec/instances/premis-in-mets",
|
28
|
-
"spec/instances/premis-in-mets/bad.xml",
|
29
|
-
"spec/instances/premis-in-mets/good.xml",
|
30
|
-
"spec/schema",
|
31
|
-
"spec/schema/fda_sip.sch",
|
32
|
-
"spec/schema/pim.sch",
|
33
|
-
"spec/schema_spec.rb",
|
34
|
-
"spec/spec_helper.rb"]
|
35
|
-
|
12
|
+
spec.files = ["schematron.gemspec", "README.md", "LICENSE.txt", '.semver']
|
13
|
+
spec.files += Dir['lib/*.rb']
|
14
|
+
spec.files += Dir['spec/**/*']
|
15
|
+
spec.files += Dir['iso-schematron-xslt1/*']
|
16
|
+
spec.add_dependency 'semver', '~> 0.1.0'
|
36
17
|
spec.add_dependency 'libxml-ruby', '~> 1.1.2'
|
37
18
|
spec.add_dependency 'libxslt-ruby', '>= 0.9.1'
|
38
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schematron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Lazzarino
|
@@ -9,9 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-08 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: semver
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.0
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: libxml-ruby
|
17
27
|
type: :runtime
|
@@ -41,18 +51,12 @@ extensions: []
|
|
41
51
|
extra_rdoc_files: []
|
42
52
|
|
43
53
|
files:
|
44
|
-
- Rakefile
|
45
54
|
- schematron.gemspec
|
46
55
|
- README.md
|
47
56
|
- LICENSE.txt
|
57
|
+
- .semver
|
48
58
|
- bin/stron
|
49
59
|
- lib/schematron.rb
|
50
|
-
- iso_impl/iso_abstract_expand.xsl
|
51
|
-
- iso_impl/iso_dsdl_include.xsl
|
52
|
-
- iso_impl/iso_schematron_skeleton_for_saxon.xsl
|
53
|
-
- iso_impl/iso_schematron_skeleton_for_xslt1.xsl
|
54
|
-
- iso_impl/iso_schematron_text.xsl
|
55
|
-
- iso_impl/iso_svrl.xsl
|
56
60
|
- spec/command_spec.rb
|
57
61
|
- spec/feature_requests_spec.rb
|
58
62
|
- spec/instances/daitss-sip/Example1.xml
|
@@ -63,6 +67,12 @@ files:
|
|
63
67
|
- spec/schema/pim.sch
|
64
68
|
- spec/schema_spec.rb
|
65
69
|
- spec/spec_helper.rb
|
70
|
+
- iso-schematron-xslt1/iso_abstract_expand.xsl
|
71
|
+
- iso-schematron-xslt1/iso_dsdl_include.xsl
|
72
|
+
- iso-schematron-xslt1/iso_schematron_message.xsl
|
73
|
+
- iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl
|
74
|
+
- iso-schematron-xslt1/iso_svrl_for_xslt1.xsl
|
75
|
+
- iso-schematron-xslt1/readme.txt
|
66
76
|
has_rdoc: true
|
67
77
|
homepage: http://github.com/flazz/schematron
|
68
78
|
licenses: []
|
data/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/rdoctask'
|
3
|
-
require 'spec/rake/spectask'
|
4
|
-
|
5
|
-
Spec::Rake::SpecTask.new('spec') do |t|
|
6
|
-
t.libs << 'lib'
|
7
|
-
t.libs << 'spec'
|
8
|
-
t.spec_opts << "--color"
|
9
|
-
# t.warning = true
|
10
|
-
# t.rcov = true
|
11
|
-
# t.rcov_opts += ["-x /Library", "-x spec"]
|
12
|
-
end
|
13
|
-
|
14
|
-
task :default => [:spec]
|