module Schematron::XSLT2
Constants
- ABSTRACT_EXPAND_PATH
- DSDL_INCLUDES_PATH
- EXE_PATH
- ISO_IMPL_DIR
- SVRL_FOR_XSLT2_PATH
Public Class Methods
compile(schematron)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Private Class Methods
create_stylesheet(content_to_transform)
click to toggle source
# File lib/schematron/xslt2.rb, line 54 def self.create_stylesheet(content_to_transform) create_temp_file(content_to_transform) { |temp_file| execute_transform(SVRL_FOR_XSLT2_PATH, temp_file.path, true) } end
execute_transform(stylesheet, schema, allow_foreign = false)
click to toggle source
# File lib/schematron/xslt2.rb, line 58 def self.execute_transform(stylesheet, schema, allow_foreign = false) cmd = "java -cp #{EXE_PATH} net.sf.saxon.Transform" cmd << " -xsl:#{stylesheet}" cmd << " -s:#{schema}" if allow_foreign cmd << ' allow-foreign=true' end %x{#{cmd}} end
expand_abstract_patterns(content_to_transform)
click to toggle source
# File lib/schematron/xslt2.rb, line 50 def self.expand_abstract_patterns(content_to_transform) create_temp_file(content_to_transform) { |temp_file| execute_transform(ABSTRACT_EXPAND_PATH, temp_file.path) } end
process_includes(content_to_transform)
click to toggle source
# File lib/schematron/xslt2.rb, line 46 def self.process_includes(content_to_transform) create_temp_file(content_to_transform) { |temp_file| execute_transform(DSDL_INCLUDES_PATH, temp_file.path) } end