schematron-nokogiri 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/schematron-nokogiri.rb +22 -3
- data/schematron-nokogiri.gemspec +1 -1
- data/spec/instances/ubl/ubl.xml +251 -0
- data/spec/schema/ubl.sch +48 -0
- data/spec/schema_spec.rb +13 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b33632e68d76f76ea490f62c98cf29432ce78d
|
4
|
+
data.tar.gz: aa5d886ca87669e4dd1f50696c61a01633c8c15f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c68f8d65a72dcd066ff6a097117dc05c11fa3549bd0bb6a80f4c22891bee0662879fb2cf1eb054a3d6ed3d9f809b040d7c8c33dbc9a1568892fff92f5b8e247
|
7
|
+
data.tar.gz: e585e51356596269c1411bcaa84220b630f9bdc06dc683a7399c2e908a61f6f9f30a98ab602c6708c4ffc57e9bfc4619e1df10dcb599c21b6b9c1aeb13b9172a
|
data/lib/schematron-nokogiri.rb
CHANGED
@@ -29,10 +29,10 @@ module SchematronNokogiri
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# Compile schematron into xsl that maps to svrl
|
32
|
-
validator_doc = xforms.inject(schema_doc) {
|
32
|
+
@validator_doc = xforms.inject(schema_doc) {
|
33
33
|
|xml, xsl| xsl.transform xml
|
34
34
|
}
|
35
|
-
@validator_xsl = Nokogiri::XSLT(validator_doc.to_s)
|
35
|
+
@validator_xsl = Nokogiri::XSLT(@validator_doc.to_s)
|
36
36
|
end
|
37
37
|
|
38
38
|
def validate(instance_doc)
|
@@ -45,13 +45,32 @@ module SchematronNokogiri
|
|
45
45
|
rule_hits(results_doc, instance_doc, 'report', '//svrl:successful-report')
|
46
46
|
end
|
47
47
|
|
48
|
+
def prefixes
|
49
|
+
namespaces = {}
|
50
|
+
|
51
|
+
@validator_doc.namespaces.each {
|
52
|
+
|k, v| namespaces[k.gsub 'xmlns:', ''] = v
|
53
|
+
}
|
54
|
+
namespaces
|
55
|
+
end
|
56
|
+
|
48
57
|
# Look for reported or failed rules of a particular type in the instance doc
|
49
58
|
def rule_hits(results_doc, instance_doc, rule_type, xpath)
|
50
59
|
|
51
60
|
results = []
|
52
61
|
|
53
62
|
results_doc.root.xpath(xpath, NS_PREFIXES).each do |hit|
|
54
|
-
|
63
|
+
context_tag = hit
|
64
|
+
context_path = nil
|
65
|
+
while context_path.nil?
|
66
|
+
context_tag = context_tag.previous_sibling
|
67
|
+
context_path = context_tag['context']
|
68
|
+
end
|
69
|
+
|
70
|
+
context = instance_doc.root.xpath(
|
71
|
+
context_path ? '/' + context_path : hit['location'],
|
72
|
+
NS_PREFIXES.merge(prefixes)
|
73
|
+
).first
|
55
74
|
|
56
75
|
hit.xpath('svrl:text/text()', NS_PREFIXES).each do |message|
|
57
76
|
results << {
|
data/schematron-nokogiri.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "schematron-nokogiri"
|
3
3
|
spec.description = "Using this gem you can validate an XML document using a ISO Schematron validation file"
|
4
|
-
spec.version = "0.0.
|
4
|
+
spec.version = "0.0.2" #SemVer.find.format '%M.%m.%p'
|
5
5
|
spec.summary = "ISO Schematron Validation using Nokogiri"
|
6
6
|
spec.email = "alexxed@gmail.com"
|
7
7
|
spec.homepage = 'https://github.com/alexxed/schematron'
|
@@ -0,0 +1,251 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Invoice xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:ccts="urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2" xmlns:stat="urn:oasis:names:specification:ubl:schema:xsd:DocumentStatusCode-1.0" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:udt="urn:un:unece:uncefact:data:draft:UnqualifiedDataTypesSchemaModule:2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
|
3
|
+
<cbc:UBLVersionID>2.0</cbc:UBLVersionID>
|
4
|
+
<cbc:CustomizationID>urn:oasis:names:specification:ubl:xpath:Invoice-2.0:sbs-1.0-draft</cbc:CustomizationID>
|
5
|
+
<cbc:ProfileID>bpid:urn:oasis:names:draft:bpss:ubl-2-sbs-invoice-notification-draft</cbc:ProfileID>
|
6
|
+
<cbc:ID>A00096678</cbc:ID>
|
7
|
+
<cbc:CopyIndicator>false</cbc:CopyIndicator>
|
8
|
+
<cbc:UUID>849FBBCE-E081-40B4-906C-94C5FF9D1A22</cbc:UUID>
|
9
|
+
<cbc:IssueDate>2005-06-21</cbc:IssueDate>
|
10
|
+
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
|
11
|
+
<cbc:Note>sample</cbc:Note>
|
12
|
+
<cbc:TaxPointDate>2005-06-21</cbc:TaxPointDate>
|
13
|
+
<cac:OrderReference>
|
14
|
+
<cbc:ID>222</cbc:ID>
|
15
|
+
<cbc:SalesOrderID>CON0095678</cbc:SalesOrderID>
|
16
|
+
<cbc:UUID>6E09886B-DC6E-439F-82D1-7CCAC7F4E3B1</cbc:UUID>
|
17
|
+
<cbc:IssueDate>2005-06-20</cbc:IssueDate>
|
18
|
+
</cac:OrderReference>
|
19
|
+
<cac:AccountingSupplierParty>
|
20
|
+
<cbc:CustomerAssignedAccountID>CO001</cbc:CustomerAssignedAccountID>
|
21
|
+
<cac:Party>
|
22
|
+
<cac:PartyIdentification>
|
23
|
+
<cbc:ID schemeID="BE:VAT">66</cbc:ID>
|
24
|
+
</cac:PartyIdentification>
|
25
|
+
<cac:PartyName>
|
26
|
+
<cbc:Name>Consortial</cbc:Name>
|
27
|
+
</cac:PartyName>
|
28
|
+
<cac:PostalAddress>
|
29
|
+
<cbc:StreetName>Busy Street</cbc:StreetName>
|
30
|
+
<cbc:BuildingName>Thereabouts</cbc:BuildingName>
|
31
|
+
<cbc:BuildingNumber>56A</cbc:BuildingNumber>
|
32
|
+
<cbc:CityName>Farthing</cbc:CityName>
|
33
|
+
<cbc:PostalZone>AA99 1BB</cbc:PostalZone>
|
34
|
+
<cbc:CountrySubentity>Heremouthshire</cbc:CountrySubentity>
|
35
|
+
<cac:AddressLine>
|
36
|
+
<cbc:Line>The Roundabout</cbc:Line>
|
37
|
+
</cac:AddressLine>
|
38
|
+
<cac:Country>
|
39
|
+
<cbc:IdentificationCode>GB</cbc:IdentificationCode>
|
40
|
+
</cac:Country>
|
41
|
+
</cac:PostalAddress>
|
42
|
+
<cac:PartyTaxScheme>
|
43
|
+
<cbc:RegistrationName>Farthing Purchasing Consortia</cbc:RegistrationName>
|
44
|
+
<cbc:CompanyID schemeID="BE:VAT">175 269 2355</cbc:CompanyID>
|
45
|
+
<cbc:ExemptionReason>N/A</cbc:ExemptionReason>
|
46
|
+
<cac:TaxScheme>
|
47
|
+
<cbc:ID>VAT</cbc:ID>
|
48
|
+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
|
49
|
+
</cac:TaxScheme>
|
50
|
+
</cac:PartyTaxScheme>
|
51
|
+
<cac:Contact>
|
52
|
+
<cbc:Name>Mrs Bouquet</cbc:Name>
|
53
|
+
<cbc:Telephone>0158 1233714</cbc:Telephone>
|
54
|
+
<cbc:Telefax>0158 1233856</cbc:Telefax>
|
55
|
+
<cbc:ElectronicMail>bouquet@fpconsortial.co.uk</cbc:ElectronicMail>
|
56
|
+
</cac:Contact>
|
57
|
+
</cac:Party>
|
58
|
+
</cac:AccountingSupplierParty>
|
59
|
+
<cac:AccountingCustomerParty>
|
60
|
+
<cbc:CustomerAssignedAccountID>XFB01</cbc:CustomerAssignedAccountID>
|
61
|
+
<cbc:SupplierAssignedAccountID>GT00978567</cbc:SupplierAssignedAccountID>
|
62
|
+
<cac:Party>
|
63
|
+
<cac:PartyIdentification>
|
64
|
+
<cbc:ID schemeID="FR:SIRENE">66</cbc:ID>
|
65
|
+
</cac:PartyIdentification>
|
66
|
+
<cac:PartyName>
|
67
|
+
<cbc:Name>IYT Corporation</cbc:Name>
|
68
|
+
</cac:PartyName>
|
69
|
+
<cac:PostalAddress>
|
70
|
+
<cbc:StreetName>Avon Way</cbc:StreetName>
|
71
|
+
<cbc:BuildingName>Thereabouts</cbc:BuildingName>
|
72
|
+
<cbc:BuildingNumber>56A</cbc:BuildingNumber>
|
73
|
+
<cbc:CityName>Bridgtow</cbc:CityName>
|
74
|
+
<cbc:PostalZone>ZZ99 1ZZ</cbc:PostalZone>
|
75
|
+
<cbc:CountrySubentity>Avon</cbc:CountrySubentity>
|
76
|
+
<cac:AddressLine>
|
77
|
+
<cbc:Line>3rd Floor, Room 5</cbc:Line>
|
78
|
+
</cac:AddressLine>
|
79
|
+
<cac:Country>
|
80
|
+
<cbc:IdentificationCode>GB</cbc:IdentificationCode>
|
81
|
+
</cac:Country>
|
82
|
+
</cac:PostalAddress>
|
83
|
+
<cac:PartyTaxScheme>
|
84
|
+
<cbc:RegistrationName>Bridgtow District Council</cbc:RegistrationName>
|
85
|
+
<cbc:CompanyID schemeID="BE-VAT">12356478</cbc:CompanyID>
|
86
|
+
<cbc:ExemptionReason>Local Authority</cbc:ExemptionReason>
|
87
|
+
<cac:TaxScheme>
|
88
|
+
<cbc:ID>UK VAT</cbc:ID>
|
89
|
+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
|
90
|
+
</cac:TaxScheme>
|
91
|
+
</cac:PartyTaxScheme>
|
92
|
+
<cac:Contact>
|
93
|
+
<cbc:Name>Mr Fred Churchill</cbc:Name>
|
94
|
+
<cbc:Telephone>0127 2653214</cbc:Telephone>
|
95
|
+
<cbc:Telefax>0127 2653215</cbc:Telefax>
|
96
|
+
<cbc:ElectronicMail>fred@iytcorporation.gov.uk</cbc:ElectronicMail>
|
97
|
+
</cac:Contact>
|
98
|
+
</cac:Party>
|
99
|
+
</cac:AccountingCustomerParty>
|
100
|
+
<cac:Delivery>
|
101
|
+
<cbc:ActualDeliveryDate>2005-06-20</cbc:ActualDeliveryDate>
|
102
|
+
<cbc:ActualDeliveryTime>11:30:00.0Z</cbc:ActualDeliveryTime>
|
103
|
+
<cac:DeliveryAddress>
|
104
|
+
<cbc:StreetName>Avon Way</cbc:StreetName>
|
105
|
+
<cbc:BuildingName>Thereabouts</cbc:BuildingName>
|
106
|
+
<cbc:BuildingNumber>56A</cbc:BuildingNumber>
|
107
|
+
<cbc:CityName>Bridgtow</cbc:CityName>
|
108
|
+
<cbc:PostalZone>ZZ99 1ZZ</cbc:PostalZone>
|
109
|
+
<cbc:CountrySubentity>Avon</cbc:CountrySubentity>
|
110
|
+
<cac:AddressLine>
|
111
|
+
<cbc:Line>3rd Floor, Room 5</cbc:Line>
|
112
|
+
</cac:AddressLine>
|
113
|
+
<cac:Country>
|
114
|
+
<cbc:IdentificationCode>GB</cbc:IdentificationCode>
|
115
|
+
</cac:Country>
|
116
|
+
</cac:DeliveryAddress>
|
117
|
+
</cac:Delivery>
|
118
|
+
<cac:PaymentMeans>
|
119
|
+
<cbc:PaymentMeansCode>20</cbc:PaymentMeansCode>
|
120
|
+
<cbc:PaymentDueDate>2005-07-21</cbc:PaymentDueDate>
|
121
|
+
<cac:PayeeFinancialAccount>
|
122
|
+
<cbc:ID>12345678</cbc:ID>
|
123
|
+
<cbc:Name>Farthing Purchasing Consortia</cbc:Name>
|
124
|
+
<cbc:AccountTypeCode>Current</cbc:AccountTypeCode>
|
125
|
+
<cbc:CurrencyCode>GBP</cbc:CurrencyCode>
|
126
|
+
<cac:FinancialInstitutionBranch>
|
127
|
+
<cbc:ID>10-26-58</cbc:ID>
|
128
|
+
<cbc:Name>Open Bank Ltd, Bridgstow Branch </cbc:Name>
|
129
|
+
<cac:FinancialInstitution>
|
130
|
+
<cbc:ID>10-26-58</cbc:ID>
|
131
|
+
<cbc:Name>Open Bank Ltd</cbc:Name>
|
132
|
+
<cac:Address>
|
133
|
+
<cbc:StreetName>City Road</cbc:StreetName>
|
134
|
+
<cbc:BuildingName>Banking House</cbc:BuildingName>
|
135
|
+
<cbc:BuildingNumber>12</cbc:BuildingNumber>
|
136
|
+
<cbc:CityName>London</cbc:CityName>
|
137
|
+
<cbc:PostalZone>AQ1 6TH</cbc:PostalZone>
|
138
|
+
<cbc:CountrySubentity>London
|
139
|
+
</cbc:CountrySubentity>
|
140
|
+
<cac:AddressLine>
|
141
|
+
<cbc:Line>5th Floor</cbc:Line>
|
142
|
+
</cac:AddressLine>
|
143
|
+
<cac:Country>
|
144
|
+
<cbc:IdentificationCode>GB</cbc:IdentificationCode>
|
145
|
+
</cac:Country>
|
146
|
+
</cac:Address>
|
147
|
+
</cac:FinancialInstitution>
|
148
|
+
<cac:Address>
|
149
|
+
<cbc:StreetName>Busy Street</cbc:StreetName>
|
150
|
+
<cbc:BuildingName>The Mall</cbc:BuildingName>
|
151
|
+
<cbc:BuildingNumber>152</cbc:BuildingNumber>
|
152
|
+
<cbc:CityName>Farthing</cbc:CityName>
|
153
|
+
<cbc:PostalZone>AA99 1BB</cbc:PostalZone>
|
154
|
+
<cbc:CountrySubentity>Heremouthshire</cbc:CountrySubentity>
|
155
|
+
<cac:AddressLine>
|
156
|
+
<cbc:Line>West Wing</cbc:Line>
|
157
|
+
</cac:AddressLine>
|
158
|
+
<cac:Country>
|
159
|
+
<cbc:IdentificationCode>GB</cbc:IdentificationCode>
|
160
|
+
</cac:Country>
|
161
|
+
</cac:Address>
|
162
|
+
</cac:FinancialInstitutionBranch>
|
163
|
+
<cac:Country>
|
164
|
+
<cbc:IdentificationCode>GB</cbc:IdentificationCode>
|
165
|
+
</cac:Country>
|
166
|
+
</cac:PayeeFinancialAccount>
|
167
|
+
</cac:PaymentMeans>
|
168
|
+
<cac:PaymentTerms>
|
169
|
+
<cbc:Note>Payable within 1 calendar month from the invoice date</cbc:Note>
|
170
|
+
</cac:PaymentTerms>
|
171
|
+
<cac:AllowanceCharge>
|
172
|
+
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
|
173
|
+
<cbc:AllowanceChargeReasonCode>17</cbc:AllowanceChargeReasonCode>
|
174
|
+
<cbc:MultiplierFactorNumeric>0.10</cbc:MultiplierFactorNumeric>
|
175
|
+
<cbc:Amount currencyID="GBP">10.00</cbc:Amount>
|
176
|
+
</cac:AllowanceCharge>
|
177
|
+
<cac:TaxTotal>
|
178
|
+
<cbc:TaxAmount currencyID="GBP">17.50</cbc:TaxAmount>
|
179
|
+
<cbc:TaxEvidenceIndicator>true</cbc:TaxEvidenceIndicator>
|
180
|
+
<cac:TaxSubtotal>
|
181
|
+
<cbc:TaxableAmount currencyID="GBP">100.00</cbc:TaxableAmount>
|
182
|
+
<cbc:TaxAmount currencyID="GBP">17.50</cbc:TaxAmount>
|
183
|
+
<cac:TaxCategory>
|
184
|
+
<cbc:ID>A</cbc:ID>
|
185
|
+
<cac:TaxScheme>
|
186
|
+
<cbc:ID>UK VAT</cbc:ID>
|
187
|
+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
|
188
|
+
</cac:TaxScheme>
|
189
|
+
</cac:TaxCategory>
|
190
|
+
</cac:TaxSubtotal>
|
191
|
+
</cac:TaxTotal>
|
192
|
+
<cac:LegalMonetaryTotal>
|
193
|
+
<cbc:LineExtensionAmount currencyID="GBP">100.00</cbc:LineExtensionAmount>
|
194
|
+
<cbc:TaxExclusiveAmount currencyID="GBP">90.00</cbc:TaxExclusiveAmount>
|
195
|
+
<cbc:TaxInclusiveAmount currencyID="EUR">107.50</cbc:TaxInclusiveAmount>
|
196
|
+
<cbc:AllowanceTotalAmount currencyID="GBP">10.00</cbc:AllowanceTotalAmount>
|
197
|
+
<cbc:PayableAmount currencyID="GBP">107.50</cbc:PayableAmount>
|
198
|
+
</cac:LegalMonetaryTotal>
|
199
|
+
<cac:InvoiceLine>
|
200
|
+
<cbc:ID>A</cbc:ID>
|
201
|
+
<cbc:InvoicedQuantity unitCode="KG">100</cbc:InvoicedQuantity>
|
202
|
+
<cbc:LineExtensionAmount currencyID="GBP">100.00</cbc:LineExtensionAmount>
|
203
|
+
<cac:OrderLineReference>
|
204
|
+
<cbc:LineID>1</cbc:LineID>
|
205
|
+
<cbc:SalesOrderLineID>A</cbc:SalesOrderLineID>
|
206
|
+
<cbc:LineStatusCode>NoStatus</cbc:LineStatusCode>
|
207
|
+
<cac:OrderReference>
|
208
|
+
<cbc:ID>AEG012345</cbc:ID>
|
209
|
+
<cbc:SalesOrderID>CON0095678</cbc:SalesOrderID>
|
210
|
+
<cbc:UUID>6E09886B-DC6E-439F-82D1-7CCAC7F4E3B1</cbc:UUID>
|
211
|
+
<cbc:IssueDate>2005-06-20</cbc:IssueDate>
|
212
|
+
</cac:OrderReference>
|
213
|
+
</cac:OrderLineReference>
|
214
|
+
<cac:TaxTotal>
|
215
|
+
<cbc:TaxAmount currencyID="GBP">17.50</cbc:TaxAmount>
|
216
|
+
<cbc:TaxEvidenceIndicator>true</cbc:TaxEvidenceIndicator>
|
217
|
+
<cac:TaxSubtotal>
|
218
|
+
<cbc:TaxableAmount currencyID="GBP">100.00</cbc:TaxableAmount>
|
219
|
+
<cbc:TaxAmount currencyID="GBP">17.50</cbc:TaxAmount>
|
220
|
+
<cac:TaxCategory>
|
221
|
+
<cbc:ID>A</cbc:ID>
|
222
|
+
<cbc:Percent>17.5</cbc:Percent>
|
223
|
+
<cac:TaxScheme>
|
224
|
+
<cbc:ID>UK VAT</cbc:ID>
|
225
|
+
<cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
|
226
|
+
</cac:TaxScheme>
|
227
|
+
</cac:TaxCategory>
|
228
|
+
</cac:TaxSubtotal>
|
229
|
+
</cac:TaxTotal>
|
230
|
+
<cac:Item>
|
231
|
+
<cbc:Description>Acme beeswax</cbc:Description>
|
232
|
+
<cbc:Name>beeswax</cbc:Name>
|
233
|
+
<cac:BuyersItemIdentification>
|
234
|
+
<cbc:ID>6578489</cbc:ID>
|
235
|
+
</cac:BuyersItemIdentification>
|
236
|
+
<cac:SellersItemIdentification>
|
237
|
+
<cbc:ID>17589683</cbc:ID>
|
238
|
+
</cac:SellersItemIdentification>
|
239
|
+
<cac:ItemInstance>
|
240
|
+
<cac:LotIdentification>
|
241
|
+
<cbc:LotNumberID>546378239</cbc:LotNumberID>
|
242
|
+
<cbc:ExpiryDate>2010-01-01</cbc:ExpiryDate>
|
243
|
+
</cac:LotIdentification>
|
244
|
+
</cac:ItemInstance>
|
245
|
+
</cac:Item>
|
246
|
+
<cac:Price>
|
247
|
+
<cbc:PriceAmount currencyID="GBP">1.00</cbc:PriceAmount>
|
248
|
+
<cbc:BaseQuantity unitCode="KG">1</cbc:BaseQuantity>
|
249
|
+
</cac:Price>
|
250
|
+
</cac:InvoiceLine>
|
251
|
+
</Invoice>
|
data/spec/schema/ubl.sch
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<schema xmlns="http://purl.oclc.org/dsdl/schematron" 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">
|
3
|
+
<title>OPENPEPPOL T10 bound to UBL</title>
|
4
|
+
<ns prefix="cbc" uri="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"/>
|
5
|
+
<ns prefix="cac" uri="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"/>
|
6
|
+
<ns prefix="ubl" uri="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"/>
|
7
|
+
<pattern name="Validate the data filled in by the sender">
|
8
|
+
|
9
|
+
<rule context="ubl:Invoice">
|
10
|
+
|
11
|
+
<assert test="cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID!=''">
|
12
|
+
formats.openpeppol.errors.supplier_party.party_tax_scheme.company_id_required
|
13
|
+
</assert>
|
14
|
+
|
15
|
+
<assert test="cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID!=''">
|
16
|
+
formats.openpeppol.errors.customer_party.party_tax_scheme.company_id_required
|
17
|
+
</assert>
|
18
|
+
|
19
|
+
<assert test="cac:PaymentMeans/cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cac:FinancialInstitution/cbc:ID!=''">
|
20
|
+
formats.openpeppol.errors.payment_means.financial_institution_id_required
|
21
|
+
</assert>
|
22
|
+
|
23
|
+
<assert test="cac:OrderReference/cbc:ID!=''">
|
24
|
+
formats.openpeppol.errors.order_reference_id_required
|
25
|
+
</assert>
|
26
|
+
|
27
|
+
</rule>
|
28
|
+
|
29
|
+
<rule context="ubl:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID//@schemeID">
|
30
|
+
<assert test="( ( not(contains(normalize-space(.),' ')) and contains( ' FR:SIRENE SE:ORGNR FR:SIRET FI:OVT DUNS GLN DK:P IT:FTI NL:KVK IT:SIA IT:SECETI DK:CPR DK:CVR DK:SE DK:VANS IT:VAT IT:CF NO:ORGNR NO:VAT HU:VAT EU:REID AT:VAT AT:GOV IS:KT IBAN AT:KUR ES:VAT IT:IPA AD:VAT AL:VAT BA:VAT BE:VAT BG:VAT CH:VAT CY:VAT CZ:VAT DE:VAT EE:VAT GB:VAT GR:VAT HR:VAT IE:VAT LI:VAT LT:VAT LU:VAT LV:VAT MC:VAT ME:VAT MK:VAT MT:VAT NL:VAT PL:VAT PT:VAT RO:VAT RS:VAT SI:VAT SK:VAT SM:VAT TR:VAT VA:VAT NL:ION SE:VAT ZZZ ',concat(' ',normalize-space(.),' ') ) ) )">formats.openpeppol.errors.accounting_customer_party_scheme_id_wrong_format</assert>
|
31
|
+
</rule>
|
32
|
+
|
33
|
+
<rule context="ubl:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID//@schemeID">
|
34
|
+
<assert test="( ( not(contains(normalize-space(.),' ')) and contains( ' FR:SIRENE SE:ORGNR FR:SIRET FI:OVT DUNS GLN DK:P IT:FTI NL:KVK IT:SIA IT:SECETI DK:CPR DK:CVR DK:SE DK:VANS IT:VAT IT:CF NO:ORGNR NO:VAT HU:VAT EU:REID AT:VAT AT:GOV IS:KT IBAN AT:KUR ES:VAT IT:IPA AD:VAT AL:VAT BA:VAT BE:VAT BG:VAT CH:VAT CY:VAT CZ:VAT DE:VAT EE:VAT GB:VAT GR:VAT HR:VAT IE:VAT LI:VAT LT:VAT LU:VAT LV:VAT MC:VAT ME:VAT MK:VAT MT:VAT NL:VAT PL:VAT PT:VAT RO:VAT RS:VAT SI:VAT SK:VAT SM:VAT TR:VAT VA:VAT NL:ION SE:VAT ZZZ ',concat(' ',normalize-space(.),' ') ) ) )">formats.openpeppol.errors.accounting_supplier_party_scheme_id_wrong_format</assert>
|
35
|
+
</rule>
|
36
|
+
|
37
|
+
<rule context="ubl:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID//@schemeID" flag="fatal">
|
38
|
+
<assert test="( ( not(contains(normalize-space(.),' ')) and contains( ' FR:SIRENE SE:ORGNR FR:SIRET FI:OVT DUNS GLN DK IT:FTI NL:KVK IT:SIA IT:SECETI DK:CPR DK:CVR DK:SE DK:VANS IT:VAT IT:CF NO:ORGNR NO:VAT HU:VAT EU:REID AT:VAT AT:GOV IS:KT IBAN AT:KUR ES:VAT IT:IPA AD:VAT AL:VAT BA:VAT BE:VAT BG:VAT CH:VAT CY:VAT CZ:VAT DE:VAT EE:VAT GB:VAT GR:VAT HR:VAT IE:VAT LI:VAT LT:VAT LU:VAT LV:VAT MC:VAT ME:VAT MK:VAT MT:VAT NL:VAT PL:VAT PT:VAT RO:VAT RS:VAT SI:VAT SK:VAT SM:VAT TR:VAT VA:VAT NL:ION SE:VAT ZZZ ',concat(' ',normalize-space(.),' ') ) ) )" flag="fatal">formats.openpeppol.errors.accounting_supplier_party.company_id_scheme_id_wrong_format
|
39
|
+
</assert>
|
40
|
+
</rule>
|
41
|
+
|
42
|
+
<rule context="ubl:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID//@schemeID" flag="fatal">
|
43
|
+
<assert test="( ( not(contains(normalize-space(.),' ')) and contains( ' FR:SIRENE SE:ORGNR FR:SIRET FI:OVT DUNS GLN DK IT:FTI NL:KVK IT:SIA IT:SECETI DK:CPR DK:CVR DK:SE DK:VANS IT:VAT IT:CF NO:ORGNR NO:VAT HU:VAT EU:REID AT:VAT AT:GOV IS:KT IBAN AT:KUR ES:VAT IT:IPA AD:VAT AL:VAT BA:VAT BE:VAT BG:VAT CH:VAT CY:VAT CZ:VAT DE:VAT EE:VAT GB:VAT GR:VAT HR:VAT IE:VAT LI:VAT LT:VAT LU:VAT LV:VAT MC:VAT ME:VAT MK:VAT MT:VAT NL:VAT PL:VAT PT:VAT RO:VAT RS:VAT SI:VAT SK:VAT SM:VAT TR:VAT VA:VAT NL:ION SE:VAT ZZZ ',concat(' ',normalize-space(.),' ') ) ) )" flag="fatal">formats.openpeppol.errors.accounting_customer_party.company_id_scheme_id_wrong_format
|
44
|
+
</assert>
|
45
|
+
</rule>
|
46
|
+
|
47
|
+
</pattern>
|
48
|
+
</schema>
|
data/spec/schema_spec.rb
CHANGED
@@ -34,6 +34,19 @@ describe SchematronNokogiri::Schema do
|
|
34
34
|
|
35
35
|
results.should_not be_empty
|
36
36
|
end
|
37
|
+
|
38
|
+
it "should detect errors for a bad ubl" do
|
39
|
+
schema_file = File.join 'spec', 'schema', 'ubl.sch'
|
40
|
+
instance_file = File.join 'spec', 'instances', 'ubl', 'ubl.xml'
|
41
|
+
|
42
|
+
schema_doc = Nokogiri::XML(File.open(schema_file))
|
43
|
+
instance_doc = Nokogiri::XML(File.open(instance_file))
|
44
|
+
|
45
|
+
stron = SchematronNokogiri::Schema.new schema_doc
|
46
|
+
results = stron.validate instance_doc
|
47
|
+
|
48
|
+
results.should_not be_empty
|
49
|
+
end
|
37
50
|
|
38
51
|
it "should log report rules in the results" do
|
39
52
|
schema_file = File.join 'spec', 'schema', 'pim.sch'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schematron-nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Lazzarino
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-11-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -51,8 +51,10 @@ files:
|
|
51
51
|
- spec/instances/daitss-sip/Example2.xml
|
52
52
|
- spec/instances/premis-in-mets/bad.xml
|
53
53
|
- spec/instances/premis-in-mets/good.xml
|
54
|
+
- spec/instances/ubl/ubl.xml
|
54
55
|
- spec/schema/fda_sip.sch
|
55
56
|
- spec/schema/pim.sch
|
57
|
+
- spec/schema/ubl.sch
|
56
58
|
- spec/schema_spec.rb
|
57
59
|
- spec/spec_helper.rb
|
58
60
|
homepage: https://github.com/alexxed/schematron
|
@@ -75,9 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
77
|
version: '0'
|
76
78
|
requirements: []
|
77
79
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.5.1
|
79
81
|
signing_key:
|
80
82
|
specification_version: 4
|
81
83
|
summary: ISO Schematron Validation using Nokogiri
|
82
84
|
test_files: []
|
83
|
-
has_rdoc:
|