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/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
data/bin/validate-sh DELETED
@@ -1,9 +0,0 @@
1
- #!/bin/sh
2
-
3
- my_schema=$1
4
- my_document=$2
5
-
6
- xsltproc iso_impl/iso_dsdl_include.xsl $my_schema | \
7
- xsltproc iso_impl/iso_abstract_expand.xsl - | \
8
- xsltproc iso_impl/iso_svrl.xsl - | \
9
- xsltproc - $my_document