schematron-nokogiri 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/schematron-nokogiri.rb +3 -3
  3. data/schematron-nokogiri.gemspec +1 -1
  4. data/spec/instances/ubl/ubl_simple_invoicing.xml +317 -0
  5. data/spec/schema/open_peppol/SI-UBL-INV-1.1.1rc2.xsl +15921 -0
  6. data/spec/schema/open_peppol/SI-UBL-INV-1.1.xsl +15921 -0
  7. data/spec/schema/open_peppol/SI-UBL-INV-STRICT.SCH +86 -0
  8. data/spec/schema/open_peppol/SI-UBL-INV.SCH +88 -0
  9. data/spec/schema/open_peppol/convert/iso_abstract_expand.xsl +297 -0
  10. data/spec/schema/open_peppol/convert/iso_dsdl_include.xsl +1509 -0
  11. data/spec/schema/open_peppol/convert/iso_schematron_message.xsl +55 -0
  12. data/spec/schema/open_peppol/convert/iso_schematron_skeleton_for_xslt1.xsl +1844 -0
  13. data/spec/schema/open_peppol/convert/iso_svrl_for_xslt1.xsl +605 -0
  14. data/spec/schema/open_peppol/general/SI-UBL-GENERAL.SCH +10 -0
  15. data/spec/schema/open_peppol/lib/saxon.jar +0 -0
  16. data/spec/schema/open_peppol/v1.0/SI-UBL-CRE-100.SCH +459 -0
  17. data/spec/schema/open_peppol/v1.0/SI-UBL-CRE-100.XSL +1298 -0
  18. data/spec/schema/open_peppol/v1.0/SI-UBL-INV-100.SCH +531 -0
  19. data/spec/schema/open_peppol/v1.0/SI-UBL-INV-100.XSL +1457 -0
  20. data/spec/schema/open_peppol/v1.0/SI-UBL-INV-V10-FATAL.SCH +45 -0
  21. data/spec/schema/open_peppol/v1.0/SI-UBL-INV-V10-WARNING.SCH +467 -0
  22. data/spec/schema/open_peppol/v1.0/biicore/abstract/BIICORE-T10.sch +433 -0
  23. data/spec/schema/open_peppol/v1.0/biicore/ubl/BIICORE-UBL-T10.sch +425 -0
  24. data/spec/schema/open_peppol/v1.0/biiprofiles/UBL/BIIPROFILES-UBL-T10.sch +14 -0
  25. data/spec/schema/open_peppol/v1.0/biiprofiles/abstract/BIIPROFILES-T10.sch +16 -0
  26. data/spec/schema/open_peppol/v1.0/biirules/UBL/BIIRULES-UBL-T10.sch +70 -0
  27. data/spec/schema/open_peppol/v1.0/biirules/abstract/BIIRULES-T10.sch +91 -0
  28. data/spec/schema/open_peppol/v1.0/biirules/codelist/BIIRULESCodesT10.sch +47 -0
  29. data/spec/schema/open_peppol/v1.0/eugen/UBL/EUGEN-UBL-T10.sch +45 -0
  30. data/spec/schema/open_peppol/v1.0/eugen/abstract/EUGEN-T10.sch +57 -0
  31. data/spec/schema/open_peppol/v1.0/eugen/codelist/EUGENCodesT10.sch +47 -0
  32. data/spec/schema/open_peppol/v1.1/BII/BIICORE-UBL-T10-V1.0.sch +6879 -0
  33. data/spec/schema/open_peppol/v1.1/BII/BIIRULES-UBL-T10.sch +28 -0
  34. data/spec/schema/open_peppol/v1.1/BII/BIIRULES-UBL-T10.xsl +1186 -0
  35. data/spec/schema/open_peppol/v1.1/BII/UBL/BIIRULES-UBL-T10.sch +80 -0
  36. data/spec/schema/open_peppol/v1.1/BII/abstract/BIIRULES-T10.sch +78 -0
  37. data/spec/schema/open_peppol/v1.1/BII/codelist/BIIRULESCodesT10-UBL.sch +55 -0
  38. data/spec/schema/open_peppol/v1.1/BII/convert.bat +7 -0
  39. data/spec/schema/open_peppol/v1.1/PEPPOL/OPENPEPPOL-UBL-T10.sch +28 -0
  40. data/spec/schema/open_peppol/v1.1/PEPPOL/UBL/OPENPEPPOL-UBL-T10.sch +62 -0
  41. data/spec/schema/open_peppol/v1.1/PEPPOL/abstract/OPENPEPPOL-T10.sch +82 -0
  42. data/spec/schema/open_peppol/v1.1/PEPPOL/codelist/OPENPEPPOLCodesT10-UBL.sch +47 -0
  43. data/spec/schema/open_peppol/v1.1/SI-UBL-INV-V11-Codes.SCH +24 -0
  44. data/spec/schema/open_peppol/v1.1/SI-UBL-INV-V11-FATAL.SCH +103 -0
  45. data/spec/schema/open_peppol/v1.1/SI-UBL-INV-V11-WARNING.SCH +498 -0
  46. data/spec/schema/open_peppol/v1.1/V1.1-Check.sch +3 -0
  47. data/spec/schema_spec.rb +12 -0
  48. metadata +45 -2
@@ -0,0 +1,86 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <schema xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" queryBinding="xslt" xmlns="http://purl.oclc.org/dsdl/schematron">
3
+ <!--
4
+ Release 1.1.1
5
+ Author: Jelte Jansen (SIDN Labs)
6
+ Changes since 1.1:
7
+ - SI-UBL version detection is now based on CustomizationID instead of UBLVersion
8
+ - Split up schematron tree into versions (v1.0 and v1.1)
9
+ - Added UBL Business rules to v1.0 checker
10
+
11
+ Release 1.1
12
+ Author: M.P. Diepstra (Innopay)
13
+ Email: support@simplerinvoicing.org
14
+
15
+ Usable XPath statements for getting insight into Schematron file:
16
+ //rule[@context=preceding-sibling::rule/@context] - - - > Gets all rules that might not get fired because they have the same context as previous rules
17
+ max(//assert/substring-before(text(), ']')) - - - > Gets the maximum number of the current error numbering in the rule set
18
+ //assert[@flag='fatal' or (not(@flag) and parent::rule/@flag='fatal')] - - - > Gets all asserts that are flagged 'fatal'
19
+ //assert[not(@flag) or @flag != parent::rule/@flag] - - - > Gets all asserts where the flag differs from the rule flag
20
+
21
+ Development comments:
22
+ To facilitate developers of invoicing software, the rules should point to the actual elements that are giving the problem. Sometimes this
23
+ is not possible, like when the element is required but it's not there, but most times this should be possible.
24
+ So instead of writing an assert with cbc:ID = 'something' you should ensure that the cbc:ID is matched in the context of the rule and the
25
+ assert then only needs to check .='something'
26
+ If the context would be a to broad match than limit it using predicates with a parent match like cbc:ID[parent::cac:TaxScheme]
27
+
28
+ TODO:
29
+ - Add calculation rules for going from taxamount to transactioncurrencyamount
30
+ - Fix PEPPOL and BII rules to ensure that they target the proper context to facilitate easier pinpointing of problems
31
+ - Fix BII rules for payable amounts calculation
32
+ - doesn't work when prepaid is filled, but payable amounts is still the same
33
+ - doesn't check payable rounding amounts correctly
34
+ - Add warnings for elements not in the core
35
+ - Decide whether or not multiple occurences of items that have macoccur of 1 should be fatal or warning
36
+ -->
37
+ <title>Simplerinvoicing invoice v1.1 bound to UBL 2.1 and OPENPEPPOL v2</title>
38
+ <ns prefix="cbc" uri="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"/>
39
+ <ns prefix="cac" uri="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"/>
40
+ <ns prefix="ubl" uri="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"/>
41
+
42
+ <phase id="invoice_phase">
43
+ <active pattern="BII-UBL-T10"/>
44
+ <active pattern="PEPPOL-UBL-T10"/>
45
+ <active pattern="SI-V11-INV"/>
46
+ </phase>
47
+ <phase id="codelist_phase">
48
+ <active pattern="BII-CodesT10"/>
49
+ <active pattern="PEPPOL-CodesT10"/>
50
+ <active pattern="SI-V11-CODES"/>
51
+ </phase>
52
+ <phase id="warning_phase">
53
+ <active pattern="SI-V11-INV-WARNING"/>
54
+ </phase>
55
+ <phase id="simplerinvoicing_compatibility_phase">
56
+ <active pattern="SI-V10-INV-FATAL"/>
57
+ <active pattern="SI-V10-INV-WARNING"/>
58
+ </phase>
59
+
60
+ <!-- basic version-independent checks -->
61
+ <include href="general/SI-UBL-GENERAL.SCH" />
62
+
63
+ <!-- SimplerInvoicing Version 1.1 -->
64
+
65
+ <include href="v1.1/BII/abstract/BIIRULES-T10.sch"/>
66
+ <include href="v1.1/BII/UBL/BIIRULES-UBL-T10.sch"/>
67
+ <include href="v1.1/BII/codelist/BIIRULESCodesT10-UBL.sch"/>
68
+
69
+ <!-- PEPPOL patterns -->
70
+ <include href="v1.1/PEPPOL/abstract/OPENPEPPOL-T10.sch"/>
71
+ <include href="v1.1/PEPPOL/UBL/OPENPEPPOL-UBL-T10.sch"/>
72
+ <include href="v1.1/PEPPOL/codelist/OPENPEPPOLCodesT10-UBL.sch"/>
73
+
74
+ <!-- and SI itself -->
75
+ <include href="v1.1/SI-UBL-INV-V11-WARNING.SCH" />
76
+ <include href="v1.1/SI-UBL-INV-V11-FATAL.SCH" />
77
+ <include href="v1.1/SI-UBL-INV-V11-Codes.SCH" />
78
+
79
+
80
+ <!-- SimplerInvoicing Version 1.0 -->
81
+ <include href="v1.0/SI-UBL-INV-V10-FATAL.SCH"/>
82
+ <include href="v1.0/SI-UBL-INV-V10-WARNING.SCH"/>
83
+
84
+ <include href="v1.0/biirules/abstract/BIIRULES-T10.sch"/>
85
+ <include href="v1.0/biirules/UBL/BIIRULES-UBL-T10.sch"/>
86
+ </schema>
@@ -0,0 +1,88 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <schema xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" queryBinding="xslt" xmlns="http://purl.oclc.org/dsdl/schematron">
3
+ <!--
4
+ Release 1.1.1
5
+ Author: Jelte Jansen (SIDN Labs)
6
+ Changes since 1.1:
7
+ - SI-UBL version detection is now based on CustomizationID instead of UBLVersion
8
+ - Split up schematron tree into versions (v1.0 and v1.1)
9
+ - Added UBL Business rules to v1.0 checker
10
+
11
+ Release 1.1
12
+ Author: M.P. Diepstra (Innopay)
13
+ Email: support@simplerinvoicing.org
14
+
15
+ Usable XPath statements for getting insight into Schematron file:
16
+ //rule[@context=preceding-sibling::rule/@context] - - - > Gets all rules that might not get fired because they have the same context as previous rules
17
+ max(//assert/substring-before(text(), ']')) - - - > Gets the maximum number of the current error numbering in the rule set
18
+ //assert[@flag='fatal' or (not(@flag) and parent::rule/@flag='fatal')] - - - > Gets all asserts that are flagged 'fatal'
19
+ //assert[not(@flag) or @flag != parent::rule/@flag] - - - > Gets all asserts where the flag differs from the rule flag
20
+
21
+ Development comments:
22
+ To facilitate developers of invoicing software, the rules should point to the actual elements that are giving the problem. Sometimes this
23
+ is not possible, like when the element is required but it's not there, but most times this should be possible.
24
+ So instead of writing an assert with cbc:ID = 'something' you should ensure that the cbc:ID is matched in the context of the rule and the
25
+ assert then only needs to check .='something'
26
+ If the context would be a to broad match than limit it using predicates with a parent match like cbc:ID[parent::cac:TaxScheme]
27
+
28
+ TODO:
29
+ - Add calculation rules for going from taxamount to transactioncurrencyamount
30
+ - Fix PEPPOL and BII rules to ensure that they target the proper context to facilitate easier pinpointing of problems
31
+ - Fix BII rules for payable amounts calculation
32
+ - doesn't work when prepaid is filled, but payable amounts is still the same
33
+ - doesn't check payable rounding amounts correctly
34
+ - Add warnings for elements not in the core
35
+ - Decide whether or not multiple occurences of items that have macoccur of 1 should be fatal or warning
36
+ -->
37
+ <title>Simplerinvoicing invoice v1.1 bound to UBL 2.1 and OPENPEPPOL v2</title>
38
+ <ns prefix="cbc" uri="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"/>
39
+ <ns prefix="cac" uri="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"/>
40
+ <ns prefix="ubl" uri="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"/>
41
+
42
+ <phase id="invoice_phase">
43
+ <active pattern="BII-UBL-T10"/>
44
+ <active pattern="PEPPOL-UBL-T10"/>
45
+ <active pattern="SI-V11-INV"/>
46
+ </phase>
47
+ <phase id="codelist_phase">
48
+ <active pattern="BII-CodesT10"/>
49
+ <active pattern="PEPPOL-CodesT10"/>
50
+ <active pattern="SI-V11-CODES"/>
51
+ </phase>
52
+ <phase id="warning_phase">
53
+ <active pattern="SI-V11-INV-WARNING"/>
54
+ </phase>
55
+ <phase id="simplerinvoicing_compatibility_phase">
56
+ <active pattern="SI-V10-INV-FATAL"/>
57
+ <active pattern="SI-V10-INV-WARNING"/>
58
+ </phase>
59
+
60
+ <!-- basic version-independent checks -->
61
+ <include href="general/SI-UBL-GENERAL.SCH" />
62
+
63
+ <!-- SimplerInvoicing Version 1.1 -->
64
+
65
+ <include href="v1.1/BII/abstract/BIIRULES-T10.sch"/>
66
+ <include href="v1.1/BII/UBL/BIIRULES-UBL-T10.sch"/>
67
+ <include href="v1.1/BII/codelist/BIIRULESCodesT10-UBL.sch"/>
68
+
69
+ <!-- PEPPOL patterns -->
70
+ <include href="v1.1/PEPPOL/abstract/OPENPEPPOL-T10.sch"/>
71
+ <include href="v1.1/PEPPOL/UBL/OPENPEPPOL-UBL-T10.sch"/>
72
+ <include href="v1.1/PEPPOL/codelist/OPENPEPPOLCodesT10-UBL.sch"/>
73
+
74
+ <!-- and SI itself -->
75
+ <include href="v1.1/SI-UBL-INV-V11-WARNING.SCH" />
76
+ <include href="v1.1/SI-UBL-INV-V11-FATAL.SCH" />
77
+ <include href="v1.1/SI-UBL-INV-V11-Codes.SCH" />
78
+
79
+
80
+ <!-- SimplerInvoicing Version 1.0 -->
81
+ <include href="v1.0/SI-UBL-INV-V10-FATAL.SCH"/>
82
+ <include href="v1.0/SI-UBL-INV-V10-WARNING.SCH"/>
83
+
84
+ <!-- Uncomment this to enable BII content checks on SI-UBL 1.0 documents
85
+ <include href="v1.0/biirules/abstract/BIIRULES-T10.sch"/>
86
+ <include href="v1.0/biirules/UBL/BIIRULES-UBL-T10.sch"/>
87
+ -->
88
+ </schema>
@@ -0,0 +1,297 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><?xar XSLT?>
2
+
3
+ <!--
4
+ OVERVIEW - iso_abstract_expand.xsl
5
+
6
+ This is a preprocessor for ISO Schematron, which implements abstract patterns.
7
+ It also
8
+ * extracts a particular schema using an ID, where there are multiple
9
+ schemas, such as when they are embedded in the same NVDL script
10
+ * experimentally, allows parameter recognition and substitution inside
11
+ text as well as @context, @test, & @select.
12
+
13
+
14
+ This should be used after iso-dsdl-include.xsl and before the skeleton or
15
+ meta-stylesheet (e.g. iso-svrl.xsl) . It only requires XSLT 1.
16
+
17
+ Each kind of inclusion can be turned off (or on) on the command line.
18
+
19
+ -->
20
+ <!--
21
+ VERSION INFORMATION
22
+ 2008-09-18 RJ
23
+ * move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
24
+
25
+ 2008-07-29 RJ
26
+ * Create. Pull out as distinct XSL in its own namespace from old iso_pre_pro.xsl
27
+ * Put everything in private namespace
28
+ * Rewrite replace_substring named template so that copyright is clear
29
+
30
+ 2008-07-24 RJ
31
+ * correct abstract patterns so for correct names: param/@name and
32
+ param/@value
33
+
34
+ 2007-01-12 RJ
35
+ * Use ISO namespace
36
+ * Use pattern/@id not pattern/@name
37
+ * Add Oliver Becker's suggests from old Schematron-love-in list for <copy>
38
+ * Add XT -ism?
39
+ 2003 RJ
40
+ * Original written for old namespace
41
+ * http://www.topologi.com/resources/iso-pre-pro.xsl
42
+ -->
43
+ <!--
44
+ LEGAL INFORMATION
45
+
46
+ Copyright (c) 2000-2008 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
47
+
48
+ This software is provided 'as-is', without any express or implied warranty.
49
+ In no event will the authors be held liable for any damages arising from
50
+ the use of this software.
51
+
52
+ Permission is granted to anyone to use this software for any purpose,
53
+ including commercial applications, and to alter it and redistribute it freely,
54
+ subject to the following restrictions:
55
+
56
+ 1. The origin of this software must not be misrepresented; you must not claim
57
+ that you wrote the original software. If you use this software in a product,
58
+ an acknowledgment in the product documentation would be appreciated but is
59
+ not required.
60
+
61
+ 2. Altered source versions must be plainly marked as such, and must not be
62
+ misrepresented as being the original software.
63
+
64
+ 3. This notice may not be removed or altered from any source distribution.
65
+ -->
66
+ <xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
67
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
68
+ xmlns:iso="http://purl.oclc.org/dsdl/schematron"
69
+ xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
70
+
71
+ xmlns:iae="http://www.schematron.com/namespace/iae"
72
+
73
+ >
74
+
75
+ <xslt:param name="schema-id"></xslt:param>
76
+
77
+
78
+ <!-- Driver for the mode -->
79
+ <xsl:template match="/">
80
+ <xsl:apply-templates select="." mode="iae:go" />
81
+ </xsl:template>
82
+
83
+
84
+ <!-- ================================================================================== -->
85
+ <!-- Normal processing rules -->
86
+ <!-- ================================================================================== -->
87
+ <!-- Output only the selected schema -->
88
+ <xslt:template match="iso:schema" >
89
+ <xsl:if test="string-length($schema-id) =0 or @id= $schema-id ">
90
+ <xslt:copy>
91
+ <xslt:copy-of select="@*" />
92
+ <xslt:apply-templates mode="iae:go" />
93
+ </xslt:copy>
94
+ </xsl:if>
95
+ </xslt:template>
96
+
97
+
98
+ <!-- Strip out any foreign elements above the Schematron schema .
99
+ -->
100
+ <xslt:template match="*[not(ancestor-or-self::iso:*)]" mode="iae:go" >
101
+ <xslt:apply-templates mode="iae:go" />
102
+ </xslt:template>
103
+
104
+
105
+ <!-- ================================================================================== -->
106
+ <!-- Handle Schematron abstract pattern preprocessing -->
107
+ <!-- abstract-to-real calls
108
+ do-pattern calls
109
+ macro-expand calls
110
+ multi-macro-expand
111
+ replace-substring -->
112
+ <!-- ================================================================================== -->
113
+
114
+ <!--
115
+ Abstract patterns allow you to say, for example
116
+
117
+ <pattern name="htmlTable" is-a="table">
118
+ <param name="row" value="html:tr"/>
119
+ <param name="cell" value="html:td" />
120
+ <param name="table" value="html:table" />
121
+ </pattern>
122
+
123
+ For a good introduction, see Uche Ogbujii's article for IBM DeveloperWorks
124
+ "Discover the flexibility of Schematron abstract patterns"
125
+ http://www-128.ibm.com/developerworks/xml/library/x-stron.html
126
+ However, note that ISO Schematron uses @name and @value attributes on
127
+ the iso:param element, and @id not @name on the pattern element.
128
+
129
+ -->
130
+
131
+ <!-- Suppress declarations of abstract patterns -->
132
+ <xslt:template match="iso:pattern[@abstract='true']" mode="iae:go" >
133
+ <xslt:comment>Suppressed abstract pattern <xslt:value-of select="@id"/> was here</xslt:comment>
134
+ </xslt:template>
135
+
136
+
137
+ <!-- Suppress uses of abstract patterns -->
138
+ <xslt:template match="iso:pattern[@is-a]" mode="iae:go" >
139
+
140
+ <xslt:comment>Start pattern based on abstract <xslt:value-of select="@is-a"/></xslt:comment>
141
+
142
+ <xslt:call-template name="iae:abstract-to-real" >
143
+ <xslt:with-param name="caller" select="@id" />
144
+ <xslt:with-param name="is-a" select="@is-a" />
145
+ </xslt:call-template>
146
+
147
+ </xslt:template>
148
+
149
+
150
+
151
+ <!-- output everything else unchanged -->
152
+ <xslt:template match="*" priority="-1" mode="iae:go" >
153
+ <xslt:copy>
154
+ <xslt:copy-of select="@*" />
155
+ <xslt:apply-templates mode="iae:go"/>
156
+ </xslt:copy>
157
+ </xslt:template>
158
+
159
+ <!-- Templates for macro expansion of abstract patterns -->
160
+ <!-- Sets up the initial conditions for the recursive call -->
161
+ <xslt:template name="iae:macro-expand">
162
+ <xslt:param name="caller"/>
163
+ <xslt:param name="text" />
164
+ <xslt:call-template name="iae:multi-macro-expand">
165
+ <xslt:with-param name="caller" select="$caller"/>
166
+ <xslt:with-param name="text" select="$text"/>
167
+ <xslt:with-param name="paramNumber" select="1"/>
168
+ </xslt:call-template>
169
+
170
+ </xslt:template>
171
+
172
+ <!-- Template to replace the current parameter and then
173
+ recurse to replace subsequent parameters. -->
174
+
175
+ <xslt:template name="iae:multi-macro-expand">
176
+ <xslt:param name="caller"/>
177
+ <xslt:param name="text" />
178
+ <xslt:param name="paramNumber" />
179
+
180
+
181
+ <xslt:choose>
182
+ <xslt:when test="//iso:pattern[@id=$caller]/iso:param[ $paramNumber]">
183
+
184
+ <xslt:call-template name="iae:multi-macro-expand">
185
+ <xslt:with-param name="caller" select="$caller"/>
186
+ <xslt:with-param name="paramNumber" select="$paramNumber + 1"/>
187
+ <xslt:with-param name="text" >
188
+ <xslt:call-template name="iae:replace-substring">
189
+ <xslt:with-param name="original" select="$text"/>
190
+ <xslt:with-param name="substring"
191
+ select="concat('$', //iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@name)"/>
192
+ <xslt:with-param name="replacement"
193
+ select="//iso:pattern[@id=$caller]/iso:param[ $paramNumber ]/@value"/>
194
+ </xslt:call-template>
195
+ </xslt:with-param>
196
+ </xslt:call-template>
197
+ </xslt:when>
198
+ <xslt:otherwise><xslt:value-of select="$text" /></xslt:otherwise>
199
+
200
+ </xslt:choose>
201
+ </xslt:template>
202
+
203
+
204
+ <!-- generate the real pattern from an abstract pattern + parameters-->
205
+ <xslt:template name="iae:abstract-to-real" >
206
+ <xslt:param name="caller"/>
207
+ <xslt:param name="is-a" />
208
+ <xslt:for-each select="//iso:pattern[@id= $is-a]">
209
+ <xslt:copy>
210
+
211
+ <xslt:choose>
212
+ <xslt:when test=" string-length( $caller ) = 0">
213
+ <xslt:attribute name="id"><xslt:value-of select="concat( generate-id(.) , $is-a)" /></xslt:attribute>
214
+ </xslt:when>
215
+ <xslt:otherwise>
216
+ <xslt:attribute name="id"><xslt:value-of select="$caller" /></xslt:attribute>
217
+ </xslt:otherwise>
218
+ </xslt:choose>
219
+
220
+ <xslt:apply-templates select="*|text()" mode="iae:do-pattern" >
221
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
222
+ </xslt:apply-templates>
223
+
224
+ </xslt:copy>
225
+ </xslt:for-each>
226
+ </xslt:template>
227
+
228
+
229
+ <!-- Generate a non-abstract pattern -->
230
+ <xslt:template mode="iae:do-pattern" match="*">
231
+ <xslt:param name="caller"/>
232
+ <xslt:copy>
233
+ <xslt:for-each select="@*[name()='test' or name()='context' or name()='select']">
234
+ <xslt:attribute name="{name()}">
235
+ <xslt:call-template name="iae:macro-expand">
236
+ <xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
237
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
238
+ </xslt:call-template>
239
+ </xslt:attribute>
240
+ </xslt:for-each>
241
+ <xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select']" />
242
+ <xsl:for-each select="node()">
243
+ <xsl:choose>
244
+ <!-- Experiment: replace macros in text as well, to allow parameterized assertions
245
+ and so on, without having to have spurious <iso:value-of> calls and multiple
246
+ delimiting -->
247
+ <xsl:when test="self::text()">
248
+ <xslt:call-template name="iae:macro-expand">
249
+ <xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
250
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
251
+ </xslt:call-template>
252
+ </xsl:when>
253
+ <xsl:otherwise>
254
+ <xslt:apply-templates select="." mode="iae:do-pattern">
255
+ <xslt:with-param name="caller"><xslt:value-of select="$caller"/></xslt:with-param>
256
+ </xslt:apply-templates>
257
+ </xsl:otherwise>
258
+ </xsl:choose>
259
+ </xsl:for-each>
260
+ </xslt:copy>
261
+ </xslt:template>
262
+
263
+ <!-- UTILITIES -->
264
+ <!-- Simple version of replace-substring function -->
265
+ <xslt:template name="iae:replace-substring">
266
+ <xslt:param name="original" />
267
+ <xslt:param name="substring" />
268
+ <xslt:param name="replacement" select="''"/>
269
+
270
+ <xsl:choose>
271
+ <xsl:when test="not($original)" />
272
+ <xsl:when test="not(string($substring))">
273
+ <xsl:value-of select="$original" />
274
+ </xsl:when>
275
+ <xsl:when test="contains($original, $substring)">
276
+ <xsl:variable name="before" select="substring-before($original, $substring)" />
277
+ <xsl:variable name="after" select="substring-after($original, $substring)" />
278
+
279
+ <xsl:value-of select="$before" />
280
+ <xsl:value-of select="$replacement" />
281
+ <!-- recursion -->
282
+ <xsl:call-template name="iae:replace-substring">
283
+ <xsl:with-param name="original" select="$after" />
284
+ <xsl:with-param name="substring" select="$substring" />
285
+ <xsl:with-param name="replacement" select="$replacement" />
286
+ </xsl:call-template>
287
+ </xsl:when>
288
+ <xsl:otherwise>
289
+ <!-- no substitution -->
290
+ <xsl:value-of select="$original" />
291
+ </xsl:otherwise>
292
+ </xsl:choose>
293
+ </xslt:template>
294
+
295
+
296
+
297
+ </xslt:stylesheet>