Module: Schematron::XSLT2
- Extended by:
- Utils
- Defined in:
- lib/schematron/xslt2.rb
Constant Summary
collapse
- ISO_IMPL_DIR =
File.join(File.dirname(__FILE__), '../..', 'iso-schematron-xslt2')
- DSDL_INCLUDES_PATH =
File.join(ISO_IMPL_DIR, 'iso_dsdl_include.xsl')
- ABSTRACT_EXPAND_PATH =
File.join(ISO_IMPL_DIR, 'iso_abstract_expand.xsl')
- SVRL_FOR_XSLT2_PATH =
File.join(ISO_IMPL_DIR, 'iso_svrl_for_xslt2.xsl')
- EXE_PATH =
File.join(File.dirname(__FILE__), '../..', 'bin/saxon9he.jar')
Class Method Summary
collapse
Methods included from Utils
create_temp_file, get_attribute_value
Class Method Details
.compile(schematron) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/schematron/xslt2.rb', line 13
def self.compile(schematron)
temp_schematron = process_includes(schematron)
temp_schematron = expand_abstract_patterns(temp_schematron)
create_stylesheet(temp_schematron)
end
|
.get_errors(validation_result) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/schematron/xslt2.rb', line 28
def self.get_errors(validation_result)
result = []
document = Nokogiri::XML(validation_result) do |config|
config.options = Nokogiri::XML::ParseOptions::NOBLANKS | Nokogiri::XML::ParseOptions::NOENT
end
document.xpath('//svrl:failed-assert').each do |element|
result.push({message: element.xpath('./svrl:text').text.strip,
role: get_attribute_value(element, '@role'),
location: get_attribute_value(element, '@location')})
end
result
end
|
.validate(stylesheet, xml) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/schematron/xslt2.rb', line 20
def self.validate(stylesheet, xml)
create_temp_file(stylesheet) do |temp_stylesheet|
create_temp_file(xml) do |temp_xml|
execute_transform(temp_stylesheet.path, temp_xml.path)
end
end
end
|