flazz-schematron 0.0.0 → 0.0.3
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/stron +27 -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 +30 -6
- 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 +51 -10
- data/bin/validate +0 -57
- data/bin/validate-sh +0 -9
data/bin/validate
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require 'libxml'
|
4
|
-
require 'libxslt'
|
5
|
-
|
6
|
-
include LibXML
|
7
|
-
include LibXSLT
|
8
|
-
|
9
|
-
# The location of the ISO schematron implemtation lives
|
10
|
-
# Change this as needed
|
11
|
-
ISO_IMPL_DIR = 'iso_impl'
|
12
|
-
|
13
|
-
# The file names of the compilation stages
|
14
|
-
ISO_FILES = [ 'iso_dsdl_include.xsl',
|
15
|
-
'iso_abstract_expand.xsl',
|
16
|
-
'iso_svrl.xsl' ]
|
17
|
-
|
18
|
-
# Namespace prefix declarations for use in XPaths
|
19
|
-
NS_PREFIXES = {
|
20
|
-
'svrl' => 'http://purl.oclc.org/dsdl/svrl'
|
21
|
-
}
|
22
|
-
|
23
|
-
# Tell the parse to remember the line numbers for each node
|
24
|
-
XML::Parser::default_line_numbers = true
|
25
|
-
|
26
|
-
# Get sch and xml from command line
|
27
|
-
schema_doc = XML::Document.file ARGV[0]
|
28
|
-
instance_doc = XML::Document.file ARGV[1]
|
29
|
-
|
30
|
-
# Compile schematron into xsl that maps to svrl
|
31
|
-
xforms = ISO_FILES.map do |file|
|
32
|
-
|
33
|
-
Dir.chdir(ISO_IMPL_DIR) do
|
34
|
-
doc = XML::Document.file file
|
35
|
-
XSLT::Stylesheet.new doc
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
validator_doc = xforms.inject(schema_doc) { |xml, xsl| xsl.apply xml }
|
41
|
-
validator_xsl = XSLT::Stylesheet.new validator_doc
|
42
|
-
|
43
|
-
# Validate the xml
|
44
|
-
results_doc = validator_xsl.apply instance_doc
|
45
|
-
|
46
|
-
# Print the errors
|
47
|
-
results_doc.root.find('//svrl:failed-assert', NS_PREFIXES).each do |assert|
|
48
|
-
context = instance_doc.root.find_first assert['location']
|
49
|
-
|
50
|
-
assert.find('svrl:text/text()', NS_PREFIXES).each do |message|
|
51
|
-
puts '%s "%s" on line %d: %s' % [ context.node_type_name,
|
52
|
-
context.name,
|
53
|
-
context.line_num,
|
54
|
-
message.content.strip ]
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|