schematron-nokogiri 0.0.1
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.
- checksums.yaml +7 -0
- data/.semver +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/bin/stron-nokogiri +34 -0
- data/iso-schematron-xslt1/iso_abstract_expand.xsl +296 -0
- data/iso-schematron-xslt1/iso_dsdl_include.xsl +1160 -0
- data/iso-schematron-xslt1/iso_schematron_message.xsl +55 -0
- data/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl +1821 -0
- data/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl +588 -0
- data/iso-schematron-xslt1/readme.txt +83 -0
- data/lib/schematron-nokogiri.rb +85 -0
- data/schematron-nokogiri.gemspec +17 -0
- 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 +35 -0
- data/spec/schema_spec.rb +54 -0
- data/spec/spec_helper.rb +1 -0
- metadata +83 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
|
2
|
+
|
3
|
+
<title>
|
4
|
+
Florida Digital Archive SIP Validation
|
5
|
+
</title>
|
6
|
+
|
7
|
+
<ns prefix="mets" uri="http://www.loc.gov/METS/"/>
|
8
|
+
<ns prefix="dts" uri="http://www.fcla.edu/dls/md/daitss/"/>
|
9
|
+
<ns prefix="xlink" uri="http://www.w3.org/1999/xlink"/>
|
10
|
+
|
11
|
+
<pattern name="Descriptor should have Agreement Info">
|
12
|
+
|
13
|
+
<rule context="/mets:mets">
|
14
|
+
<assert test="mets:amdSec/mets:digiprovMD/mets:mdWrap/mets:xmlData/dts:daitss/dts:AGREEMENT_INFO">
|
15
|
+
A digiprovMD wrapping an AGREEMENT_INFO element is required
|
16
|
+
</assert>
|
17
|
+
</rule>
|
18
|
+
|
19
|
+
<rule context="//dts:AGREEMENT_INFO">
|
20
|
+
<assert test="@ACCOUNT">Agreement Info must have an account</assert>
|
21
|
+
<assert test="@PROJECT">Agreement Info must have a project</assert>
|
22
|
+
</rule>
|
23
|
+
|
24
|
+
</pattern>
|
25
|
+
|
26
|
+
<pattern name="All files must have a location">
|
27
|
+
<rule context="//mets:file">
|
28
|
+
<assert test="mets:FLocat">a file must have a location</assert>
|
29
|
+
<assert test="mets:FLocat/@xlink:href">a file location must have a path reference</assert>
|
30
|
+
</rule>
|
31
|
+
</pattern>
|
32
|
+
|
33
|
+
<pattern name="All file checksums must be proper MD5 or SHA-1">
|
34
|
+
|
35
|
+
<rule context="//mets:file[@CHECKSUM and @CHECKSUMTYPE = 'MD5']">
|
36
|
+
<assert test="string-length(@CHECKSUM) = 32">
|
37
|
+
MD5 must be 32 characters
|
38
|
+
</assert>
|
39
|
+
<assert test="string-length(translate(@CHECKSUM, '0987654321abcdefABCDEF', '')) = 0">
|
40
|
+
MD5 must be only characters 0-9, A-Z, a-z
|
41
|
+
</assert>
|
42
|
+
</rule>
|
43
|
+
|
44
|
+
<rule context="//mets:file[@CHECKSUM and @CHECKSUMTYPE = 'SHA-1']">
|
45
|
+
<assert test="string-length(@CHECKSUM) = 40">
|
46
|
+
SHA-1 must be 40 characters
|
47
|
+
</assert>
|
48
|
+
<assert test="string-length(translate(@CHECKSUM, '0987654321abcdefABCDEF', '')) = 0">
|
49
|
+
SHA-1 must be only characters 0-9, A-Z, a-z
|
50
|
+
</assert>
|
51
|
+
</rule>
|
52
|
+
|
53
|
+
</pattern>
|
54
|
+
|
55
|
+
<pattern name="All files must be referenced in the structMap">
|
56
|
+
<rule context="//mets:file">
|
57
|
+
<assert test="./@ID = //mets:fptr/@FILEID">
|
58
|
+
file must be referenced in the structMap
|
59
|
+
</assert>
|
60
|
+
</rule>
|
61
|
+
</pattern>
|
62
|
+
|
63
|
+
<pattern name="All fptr in the structMap should point to a file">
|
64
|
+
<rule context="//mets:fptr">
|
65
|
+
<assert test="./@FILEID = //mets:file/@ID">
|
66
|
+
file pointer must reference a file
|
67
|
+
</assert>
|
68
|
+
</rule>
|
69
|
+
</pattern>
|
70
|
+
|
71
|
+
|
72
|
+
</schema>
|
data/spec/schema/pim.sch
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
|
2
|
+
|
3
|
+
<title>
|
4
|
+
Florida Digital Archive SIP Validation
|
5
|
+
</title>
|
6
|
+
|
7
|
+
<ns prefix="mets" uri="http://www.loc.gov/METS/"/>
|
8
|
+
<ns prefix="pre" uri="info:lc/xmlns/premis-v2"/>
|
9
|
+
<ns prefix="dts" uri="http://www.fcla.edu/dls/md/daitss/"/>
|
10
|
+
|
11
|
+
<pattern name="PREMIS object should bein the proper buckets">
|
12
|
+
|
13
|
+
<rule context="//pre:event">
|
14
|
+
<assert test="parent::mets:xmlData/parent::mets:mdWrap/parent::mets:digiprovMD">
|
15
|
+
PREMIS events must be contained in a METS digiprovMD
|
16
|
+
</assert>
|
17
|
+
</rule>
|
18
|
+
|
19
|
+
<rule context="//pre:object">
|
20
|
+
<assert test="parent::mets:xmlData/parent::mets:mdWrap/parent::mets:techMD">
|
21
|
+
PREMIS objects must be contained in a METS techMD
|
22
|
+
</assert>
|
23
|
+
</rule>
|
24
|
+
|
25
|
+
</pattern>
|
26
|
+
|
27
|
+
<pattern name="METS should have embedded PREMIS">
|
28
|
+
<rule context="mets:mets">
|
29
|
+
<report test="not(//mets:mdWrap[@MDTYPE='PREMIS'])">
|
30
|
+
This METS file has no embedded PREMIS
|
31
|
+
</report>
|
32
|
+
</rule>
|
33
|
+
</pattern>
|
34
|
+
|
35
|
+
</schema>
|
data/spec/schema_spec.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'schematron-nokogiri'
|
3
|
+
|
4
|
+
describe SchematronNokogiri::Schema do
|
5
|
+
|
6
|
+
it "should load a schema from a libxml document" do
|
7
|
+
file = File.join "spec", "schema", "pim.sch"
|
8
|
+
doc = Nokogiri::XML(File.open(file))
|
9
|
+
lambda { SchematronNokogiri::Schema.new doc }.should_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should validate a good instance doc" do
|
13
|
+
schema_file = File.join 'spec', 'schema', 'fda_sip.sch'
|
14
|
+
instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example1.xml'
|
15
|
+
|
16
|
+
schema_doc = Nokogiri::XML(File.open(schema_file))
|
17
|
+
instance_doc = Nokogiri::XML(File.open(instance_file))
|
18
|
+
|
19
|
+
stron = SchematronNokogiri::Schema.new schema_doc
|
20
|
+
results = stron.validate instance_doc
|
21
|
+
|
22
|
+
results.should be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should detect errors for a bad document" do
|
26
|
+
schema_file = File.join 'spec', 'schema', 'fda_sip.sch'
|
27
|
+
instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example2.xml'
|
28
|
+
|
29
|
+
schema_doc = Nokogiri::XML(File.open(schema_file))
|
30
|
+
instance_doc = Nokogiri::XML(File.open(instance_file))
|
31
|
+
|
32
|
+
stron = SchematronNokogiri::Schema.new schema_doc
|
33
|
+
results = stron.validate instance_doc
|
34
|
+
|
35
|
+
results.should_not be_empty
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should log report rules in the results" do
|
39
|
+
schema_file = File.join 'spec', 'schema', 'pim.sch'
|
40
|
+
instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example1.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.length.should == 1
|
49
|
+
results.first[:rule_type].should == 'report'
|
50
|
+
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# nothing here yet
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: schematron-nokogiri
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Francesco Lazzarino
|
8
|
+
- Alexandru Szasz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.6'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.6'
|
28
|
+
description: Using this gem you can validate an XML document using a ISO Schematron
|
29
|
+
validation file
|
30
|
+
email: alexxed@gmail.com
|
31
|
+
executables:
|
32
|
+
- stron-nokogiri
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".semver"
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- bin/stron-nokogiri
|
40
|
+
- iso-schematron-xslt1/iso_abstract_expand.xsl
|
41
|
+
- iso-schematron-xslt1/iso_dsdl_include.xsl
|
42
|
+
- iso-schematron-xslt1/iso_schematron_message.xsl
|
43
|
+
- iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl
|
44
|
+
- iso-schematron-xslt1/iso_svrl_for_xslt1.xsl
|
45
|
+
- iso-schematron-xslt1/readme.txt
|
46
|
+
- lib/schematron-nokogiri.rb
|
47
|
+
- schematron-nokogiri.gemspec
|
48
|
+
- spec/command_spec.rb
|
49
|
+
- spec/feature_requests_spec.rb
|
50
|
+
- spec/instances/daitss-sip/Example1.xml
|
51
|
+
- spec/instances/daitss-sip/Example2.xml
|
52
|
+
- spec/instances/premis-in-mets/bad.xml
|
53
|
+
- spec/instances/premis-in-mets/good.xml
|
54
|
+
- spec/schema/fda_sip.sch
|
55
|
+
- spec/schema/pim.sch
|
56
|
+
- spec/schema_spec.rb
|
57
|
+
- spec/spec_helper.rb
|
58
|
+
homepage: https://github.com/alexxed/schematron
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.4.8
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: ISO Schematron Validation using Nokogiri
|
82
|
+
test_files: []
|
83
|
+
has_rdoc:
|