schematron 0.0.1 → 0.0.2
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/{validate → stron} +0 -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 +27 -4
- 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 +28 -6
- data/bin/validate-sh +0 -9
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'schematron'
|
3
|
+
|
4
|
+
describe "validate executable" do
|
5
|
+
|
6
|
+
it "should take only a schema and an instance document" do
|
7
|
+
`ruby -Ilib bin/stron theschema`.should =~ /Usage: /
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should validate a good instance doc" do
|
11
|
+
schema = 'spec/schema/fda_sip.sch'
|
12
|
+
instance = 'spec/instances/daitss-sip/Example1.xml'
|
13
|
+
`ruby -Ilib bin/stron #{schema} #{instance}`.should be_empty
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should print errors to standard out" do
|
17
|
+
schema = 'spec/schema/fda_sip.sch'
|
18
|
+
instance = 'spec/instances/daitss-sip/Example2.xml'
|
19
|
+
`ruby -Ilib bin/stron #{schema} #{instance}`.should =~ /^element "file" on line 48/
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<mets xmlns="http://www.loc.gov/METS/"
|
2
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
3
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
4
|
+
xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/version17/mets.v1-7.xsd
|
5
|
+
http://www.fcla.edu/dls/md/daitss/ http://www.fcla.edu/dls/md/daitss/daitss.xsd">
|
6
|
+
<amdSec>
|
7
|
+
|
8
|
+
<!-- required agreement info -->
|
9
|
+
<digiprovMD ID="digiprov-1">
|
10
|
+
<mdWrap MDTYPE="OTHER" OTHERMDTYPE="DATISS">
|
11
|
+
<xmlData>
|
12
|
+
<daitss xmlns="http://www.fcla.edu/dls/md/daitss/">
|
13
|
+
<AGREEMENT_INFO ACCOUNT="YOUR_ACCOUNT" PROJECT="THIS_PROJECT"/>
|
14
|
+
</daitss>
|
15
|
+
</xmlData>
|
16
|
+
</mdWrap>
|
17
|
+
</digiprovMD>
|
18
|
+
|
19
|
+
</amdSec>
|
20
|
+
|
21
|
+
<!-- must have checksum, checksum type & file location -->
|
22
|
+
<fileSec>
|
23
|
+
<fileGrp>
|
24
|
+
<file ID="file-1" xCHECKSUM="5ddb5736a014619bbbb3684bc6ae1613" CHECKSUMTYPE="MD5">
|
25
|
+
<FLocat LOCTYPE="URL" xlink:href="content_file"/>
|
26
|
+
</file>
|
27
|
+
</fileGrp>
|
28
|
+
</fileSec>
|
29
|
+
|
30
|
+
<!-- struct map can be fashioned in any way valid to mets -->
|
31
|
+
<structMap>
|
32
|
+
<div>
|
33
|
+
<fptr FILEID="file-1"/>
|
34
|
+
</div>
|
35
|
+
</structMap>
|
36
|
+
|
37
|
+
</mets>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<mets xmlns="http://www.loc.gov/METS/"
|
2
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
3
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
4
|
+
xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/version17/mets.v1-7.xsd
|
5
|
+
http://www.fcla.edu/dls/md/daitss/ http://www.fcla.edu/dls/md/daitss/daitss.xsd">
|
6
|
+
<amdSec>
|
7
|
+
|
8
|
+
<!-- required agreement info -->
|
9
|
+
<digiprovMD ID="digiprov-1">
|
10
|
+
<mdWrap MDTYPE="OTHER" OTHERMDTYPE="DATISS">
|
11
|
+
<xmlData>
|
12
|
+
<daitss xmlns="http://www.fcla.edu/dls/md/daitss/">
|
13
|
+
<AGREEMENT_INFO ACCOUNT="YOUR_ACCOUNT" PROJECT="THIS_PROJECT"/>
|
14
|
+
</daitss>
|
15
|
+
</xmlData>
|
16
|
+
</mdWrap>
|
17
|
+
</digiprovMD>
|
18
|
+
|
19
|
+
</amdSec>
|
20
|
+
|
21
|
+
<!-- must have checksum, checksum type & file location -->
|
22
|
+
<fileSec>
|
23
|
+
<fileGrp>
|
24
|
+
<file ID="file-1" CHECKSUM="259c4fabf48fd8fa664fb7123e470624" CHECKSUMTYPE="MD5">
|
25
|
+
<FLocat LOCTYPE="URL" xlink:href="xxx/content_file_1"/>
|
26
|
+
</file>
|
27
|
+
|
28
|
+
<file ID="file-2" CHECKSUM="6913536569c62bb11a4bb453e0553a56" CHECKSUMTYPE="MD5">
|
29
|
+
<FLocat LOCTYPE="URL" xlink:href="xxx/content_file_2"/>
|
30
|
+
</file>
|
31
|
+
|
32
|
+
<file ID="file-3" CHECKSUM="5ddb5736a014619bbbb3684bc6ae1613" CHECKSUMTYPE="MD5">
|
33
|
+
<FLocat LOCTYPE="URL" xlink:href="xxx/content_file_3"/>
|
34
|
+
</file>
|
35
|
+
|
36
|
+
<file ID="file-4" CHECKSUM="1bd851567835a6b6ce0b78502f1d0abe" CHECKSUMTYPE="MD5">
|
37
|
+
<FLocat LOCTYPE="URL" xlink:href="xxx/content_file_4"/>
|
38
|
+
</file>
|
39
|
+
|
40
|
+
<file ID="file-5" CHECKSUM="545976801e805db1c77cb9f4fa55c051" CHECKSUMTYPE="MD5">
|
41
|
+
<FLocat LOCTYPE="URL" xlink:href="xxx/content_file_5"/>
|
42
|
+
</file>
|
43
|
+
|
44
|
+
<file ID="file-6">
|
45
|
+
<FLocat LOCTYPE="URL" xlink:href="xxx/content_file_6"/>
|
46
|
+
</file>
|
47
|
+
|
48
|
+
<file ID="file-7" CHECKSUM="bfb0cf6095cd5ab3837119b11d3f285500000000z" CHECKSUMTYPE="SHA-1">
|
49
|
+
<FLocat LOCTYPE="URL" xlink:href="xxx/content_file_7"/>
|
50
|
+
</file>
|
51
|
+
|
52
|
+
</fileGrp>
|
53
|
+
</fileSec>
|
54
|
+
|
55
|
+
<!-- struct map can be fashioned in any way valid to mets -->
|
56
|
+
<structMap>
|
57
|
+
<div>
|
58
|
+
<fptr FILEID="file-1"/>
|
59
|
+
<fptr FILEID="file-2"/>
|
60
|
+
<fptr FILEID="file-3"/>
|
61
|
+
<fptr FILEID="file-4"/>
|
62
|
+
<fptr FILEID="file-5"/>
|
63
|
+
<fptr FILEID="file-6"/>
|
64
|
+
<fptr FILEID="file-7"/>
|
65
|
+
</div>
|
66
|
+
</structMap>
|
67
|
+
|
68
|
+
</mets>
|
@@ -0,0 +1,102 @@
|
|
1
|
+
<!-- Example showing PREMIS in METS -->
|
2
|
+
|
3
|
+
<mets xmlns="http://www.loc.gov/METS/"
|
4
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
6
|
+
xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/version17/mets.v1-7.xsd
|
7
|
+
http://www.fcla.edu/dls/md/daitss/ http://www.fcla.edu/dls/md/daitss/daitss.xsd">
|
8
|
+
<amdSec>
|
9
|
+
|
10
|
+
|
11
|
+
<!-- WRONG: digiprovMD/object -->
|
12
|
+
<digiprovMD ID="digiprov-1">
|
13
|
+
<mdWrap MDTYPE="PREMIS">
|
14
|
+
<xmlData>
|
15
|
+
|
16
|
+
<object xmlns="info:lc/xmlns/premis-v2" xsi:type="file">
|
17
|
+
<objectIdentifier>
|
18
|
+
<objectIdentifierType>DAITSS2</objectIdentifierType>
|
19
|
+
<objectIdentifierValue>daitss://archive.fcla.edu/p926/f0</objectIdentifierValue>
|
20
|
+
</objectIdentifier>
|
21
|
+
<objectCharacteristics>
|
22
|
+
<compositionLevel>0</compositionLevel>
|
23
|
+
<fixity>
|
24
|
+
<messageDigestAlgorithm>MD5</messageDigestAlgorithm>
|
25
|
+
<messageDigest>2de9ef79df730f93e40819625cf7bcb2</messageDigest>
|
26
|
+
</fixity>
|
27
|
+
<size>3001452</size>
|
28
|
+
<format>
|
29
|
+
<formatDesignation>
|
30
|
+
<formatName>TIFF</formatName>
|
31
|
+
<formatVersion>4.0</formatVersion>
|
32
|
+
</formatDesignation>
|
33
|
+
<formatRegistry>
|
34
|
+
<formatRegistryName>http://www.nationalarchives.gov.uk/pronom</formatRegistryName>
|
35
|
+
<formatRegistryKey>fmt/8</formatRegistryKey>
|
36
|
+
</formatRegistry>
|
37
|
+
</format>
|
38
|
+
</objectCharacteristics>
|
39
|
+
<storage>
|
40
|
+
<contentLocation>
|
41
|
+
<contentLocationType>URL</contentLocationType>
|
42
|
+
<contentLocationValue>http://archive.fcla.edu:5000/silos/gainesville-1/p926</contentLocationValue>
|
43
|
+
</contentLocation>
|
44
|
+
<storageMedium>Hard disk</storageMedium>
|
45
|
+
</storage>
|
46
|
+
</object>
|
47
|
+
|
48
|
+
</xmlData>
|
49
|
+
</mdWrap>
|
50
|
+
</digiprovMD>
|
51
|
+
|
52
|
+
<!-- WRONG techMD/event -->
|
53
|
+
<techMD ID="tech-1">
|
54
|
+
<mdWrap MDTYPE="PREMIS">
|
55
|
+
<xmlData>
|
56
|
+
|
57
|
+
<event xmlns="info:lc/xmlns/premis-v2">
|
58
|
+
<eventIdentifier>
|
59
|
+
<eventIdentifierType>DAITSS</eventIdentifierType>
|
60
|
+
<eventIdentifierValue>1</eventIdentifierValue>
|
61
|
+
</eventIdentifier>
|
62
|
+
<eventType>Format Validation</eventType>
|
63
|
+
<eventDateTime>2008-05-06T10:40:22-04:00</eventDateTime>
|
64
|
+
<eventOutcomeInformation>
|
65
|
+
<eventOutcome>Invalid</eventOutcome>
|
66
|
+
<eventOutcomeDetail>
|
67
|
+
<eventOutcomeDetailExtension>
|
68
|
+
<anomaly>ill-formed DateTime value</anomaly>
|
69
|
+
</eventOutcomeDetailExtension>
|
70
|
+
</eventOutcomeDetail>
|
71
|
+
</eventOutcomeInformation>
|
72
|
+
<linkingAgentIdentifier>
|
73
|
+
<linkingAgentIdentifierType>URI</linkingAgentIdentifierType>
|
74
|
+
<linkingAgentIdentifierValue>http://archive.fcla.edu/format-description</linkingAgentIdentifierValue>
|
75
|
+
</linkingAgentIdentifier>
|
76
|
+
<linkingObjectIdentifier>
|
77
|
+
<linkingObjectIdentifierType>DAITSS2</linkingObjectIdentifierType>
|
78
|
+
<linkingObjectIdentifierValue>daitss://archive.fcla.edu/p926/f0</linkingObjectIdentifierValue>
|
79
|
+
</linkingObjectIdentifier>
|
80
|
+
</event>
|
81
|
+
|
82
|
+
</xmlData>
|
83
|
+
</mdWrap>
|
84
|
+
</techMD>
|
85
|
+
|
86
|
+
</amdSec>
|
87
|
+
|
88
|
+
<fileSec>
|
89
|
+
<fileGrp>
|
90
|
+
<file ID="file-1" CHECKSUM="5ddb5736a014619bbbb3684bc6ae1613" CHECKSUMTYPE="MD5">
|
91
|
+
<FLocat LOCTYPE="URL" xlink:href="content_file"/>
|
92
|
+
</file>
|
93
|
+
</fileGrp>
|
94
|
+
</fileSec>
|
95
|
+
|
96
|
+
<structMap>
|
97
|
+
<div>
|
98
|
+
<fptr FILEID="file-1"/>
|
99
|
+
</div>
|
100
|
+
</structMap>
|
101
|
+
|
102
|
+
</mets>
|
@@ -0,0 +1,103 @@
|
|
1
|
+
<!-- Example showing PREMIS in METS -->
|
2
|
+
|
3
|
+
<mets xmlns="http://www.loc.gov/METS/"
|
4
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
6
|
+
xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/version17/mets.v1-7.xsd
|
7
|
+
http://www.fcla.edu/dls/md/daitss/ http://www.fcla.edu/dls/md/daitss/daitss.xsd">
|
8
|
+
<amdSec>
|
9
|
+
|
10
|
+
|
11
|
+
<!-- techMD/object -->
|
12
|
+
<techMD ID="tech-1">
|
13
|
+
<mdWrap MDTYPE="PREMIS">
|
14
|
+
<xmlData>
|
15
|
+
|
16
|
+
<object xmlns="info:lc/xmlns/premis-v2" xsi:type="file">
|
17
|
+
<objectIdentifier>
|
18
|
+
<objectIdentifierType>DAITSS2</objectIdentifierType>
|
19
|
+
<objectIdentifierValue>daitss://archive.fcla.edu/p926/f0</objectIdentifierValue>
|
20
|
+
</objectIdentifier>
|
21
|
+
<objectCharacteristics>
|
22
|
+
<compositionLevel>0</compositionLevel>
|
23
|
+
<fixity>
|
24
|
+
<messageDigestAlgorithm>MD5</messageDigestAlgorithm>
|
25
|
+
<messageDigest>2de9ef79df730f93e40819625cf7bcb2</messageDigest>
|
26
|
+
</fixity>
|
27
|
+
<size>3001452</size>
|
28
|
+
<format>
|
29
|
+
<formatDesignation>
|
30
|
+
<formatName>TIFF</formatName>
|
31
|
+
<formatVersion>4.0</formatVersion>
|
32
|
+
</formatDesignation>
|
33
|
+
<formatRegistry>
|
34
|
+
<formatRegistryName>http://www.nationalarchives.gov.uk/pronom</formatRegistryName>
|
35
|
+
<formatRegistryKey>fmt/8</formatRegistryKey>
|
36
|
+
</formatRegistry>
|
37
|
+
</format>
|
38
|
+
</objectCharacteristics>
|
39
|
+
<storage>
|
40
|
+
<contentLocation>
|
41
|
+
<contentLocationType>URL</contentLocationType>
|
42
|
+
<contentLocationValue>http://archive.fcla.edu:5000/silos/gainesville-1/p926</contentLocationValue>
|
43
|
+
</contentLocation>
|
44
|
+
<storageMedium>Hard disk</storageMedium>
|
45
|
+
</storage>
|
46
|
+
</object>
|
47
|
+
|
48
|
+
</xmlData>
|
49
|
+
</mdWrap>
|
50
|
+
</techMD>
|
51
|
+
|
52
|
+
|
53
|
+
<!-- digiprovMD/event -->
|
54
|
+
<digiprovMD ID="digiprov-1">
|
55
|
+
<mdWrap MDTYPE="PREMIS">
|
56
|
+
<xmlData>
|
57
|
+
|
58
|
+
<event xmlns="info:lc/xmlns/premis-v2">
|
59
|
+
<eventIdentifier>
|
60
|
+
<eventIdentifierType>DAITSS</eventIdentifierType>
|
61
|
+
<eventIdentifierValue>1</eventIdentifierValue>
|
62
|
+
</eventIdentifier>
|
63
|
+
<eventType>Format Validation</eventType>
|
64
|
+
<eventDateTime>2008-05-06T10:40:22-04:00</eventDateTime>
|
65
|
+
<eventOutcomeInformation>
|
66
|
+
<eventOutcome>Invalid</eventOutcome>
|
67
|
+
<eventOutcomeDetail>
|
68
|
+
<eventOutcomeDetailExtension>
|
69
|
+
<anomaly>ill-formed DateTime value</anomaly>
|
70
|
+
</eventOutcomeDetailExtension>
|
71
|
+
</eventOutcomeDetail>
|
72
|
+
</eventOutcomeInformation>
|
73
|
+
<linkingAgentIdentifier>
|
74
|
+
<linkingAgentIdentifierType>URI</linkingAgentIdentifierType>
|
75
|
+
<linkingAgentIdentifierValue>http://archive.fcla.edu/format-description</linkingAgentIdentifierValue>
|
76
|
+
</linkingAgentIdentifier>
|
77
|
+
<linkingObjectIdentifier>
|
78
|
+
<linkingObjectIdentifierType>DAITSS2</linkingObjectIdentifierType>
|
79
|
+
<linkingObjectIdentifierValue>daitss://archive.fcla.edu/p926/f0</linkingObjectIdentifierValue>
|
80
|
+
</linkingObjectIdentifier>
|
81
|
+
</event>
|
82
|
+
|
83
|
+
</xmlData>
|
84
|
+
</mdWrap>
|
85
|
+
</digiprovMD>
|
86
|
+
|
87
|
+
</amdSec>
|
88
|
+
|
89
|
+
<fileSec>
|
90
|
+
<fileGrp>
|
91
|
+
<file ID="file-1" CHECKSUM="5ddb5736a014619bbbb3684bc6ae1613" CHECKSUMTYPE="MD5">
|
92
|
+
<FLocat LOCTYPE="URL" xlink:href="content_file"/>
|
93
|
+
</file>
|
94
|
+
</fileGrp>
|
95
|
+
</fileSec>
|
96
|
+
|
97
|
+
<structMap>
|
98
|
+
<div>
|
99
|
+
<fptr FILEID="file-1"/>
|
100
|
+
</div>
|
101
|
+
</structMap>
|
102
|
+
|
103
|
+
</mets>
|
@@ -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,27 @@
|
|
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
|
+
</schema>
|
data/spec/schema_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'schematron'
|
3
|
+
require 'libxml'
|
4
|
+
|
5
|
+
include LibXML
|
6
|
+
|
7
|
+
describe Schematron::Schema do
|
8
|
+
|
9
|
+
it "should load a schema from a libxml document" do
|
10
|
+
file = File.join "spec", "schema", "pim.sch"
|
11
|
+
parser = XML::Parser.file file
|
12
|
+
doc = parser.parse
|
13
|
+
XML.default_line_numbers = true
|
14
|
+
lambda { Schematron::Schema.new doc }.should_not raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should validate a good instance doc" do
|
18
|
+
schema_file = File.join 'spec', 'schema', 'fda_sip.sch'
|
19
|
+
instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example1.xml'
|
20
|
+
|
21
|
+
schema_doc = XML::Parser.file(schema_file).parse
|
22
|
+
instance_doc = XML::Parser.file(instance_file).parse
|
23
|
+
|
24
|
+
stron = Schematron::Schema.new schema_doc
|
25
|
+
results = stron.validate instance_doc
|
26
|
+
|
27
|
+
results.should be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should detect errors for a bad document" do
|
31
|
+
schema_file = File.join 'spec', 'schema', 'fda_sip.sch'
|
32
|
+
instance_file = File.join 'spec', 'instances', 'daitss-sip', 'Example2.xml'
|
33
|
+
|
34
|
+
schema_doc = XML::Parser.file(schema_file).parse
|
35
|
+
instance_doc = XML::Parser.file(instance_file).parse
|
36
|
+
|
37
|
+
stron = Schematron::Schema.new schema_doc
|
38
|
+
results = stron.validate instance_doc
|
39
|
+
|
40
|
+
results.should_not be_empty
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# nothing here yet
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Lazzarino
|
@@ -15,8 +15,8 @@ dependencies: []
|
|
15
15
|
|
16
16
|
description:
|
17
17
|
email: flazzarino@gmail.com
|
18
|
-
executables:
|
19
|
-
|
18
|
+
executables:
|
19
|
+
- stron
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files: []
|
@@ -24,8 +24,30 @@ extra_rdoc_files: []
|
|
24
24
|
files:
|
25
25
|
- Rakefile
|
26
26
|
- schematron.gemspec
|
27
|
-
-
|
28
|
-
-
|
27
|
+
- README
|
28
|
+
- LICENSE.txt
|
29
|
+
- bin/stron
|
30
|
+
- lib/schematron.rb
|
31
|
+
- iso_impl/iso_abstract_expand.xsl
|
32
|
+
- iso_impl/iso_dsdl_include.xsl
|
33
|
+
- iso_impl/iso_schematron_skeleton_for_saxon.xsl
|
34
|
+
- iso_impl/iso_schematron_skeleton_for_xslt1.xsl
|
35
|
+
- iso_impl/iso_schematron_text.xsl
|
36
|
+
- iso_impl/iso_svrl.xsl
|
37
|
+
- spec/command_spec.rb
|
38
|
+
- spec/feature_requests_spec.rb
|
39
|
+
- spec/instances
|
40
|
+
- spec/instances/daitss-sip
|
41
|
+
- spec/instances/daitss-sip/Example1.xml
|
42
|
+
- spec/instances/daitss-sip/Example2.xml
|
43
|
+
- spec/instances/premis-in-mets
|
44
|
+
- spec/instances/premis-in-mets/bad.xml
|
45
|
+
- spec/instances/premis-in-mets/good.xml
|
46
|
+
- spec/schema
|
47
|
+
- spec/schema/fda_sip.sch
|
48
|
+
- spec/schema/pim.sch
|
49
|
+
- spec/schema_spec.rb
|
50
|
+
- spec/spec_helper.rb
|
29
51
|
has_rdoc: true
|
30
52
|
homepage: http://github.com/flazz/iso-schematron
|
31
53
|
post_install_message:
|
@@ -47,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
69
|
version:
|
48
70
|
requirements: []
|
49
71
|
|
50
|
-
rubyforge_project:
|
72
|
+
rubyforge_project: schematron
|
51
73
|
rubygems_version: 1.3.1
|
52
74
|
signing_key:
|
53
75
|
specification_version: 2
|