Class: Mtk_xslt::Saxon

Inherits:
Object show all
Defined in:
lib/ontomde-core/xslt.rb

Constant Summary collapse

TRANSFORMER_FACTORY_IMPL =
"net.sf.saxon.TransformerFactoryImpl"

Instance Method Summary collapse

Constructor Details

#initializeSaxon

Returns a new instance of Saxon.

Raises:

  • (Exception)


45
46
47
48
49
# File 'lib/ontomde-core/xslt.rb', line 45

def initialize
  System.setProperty("javax.xml.transform.TransformerFactory", TRANSFORMER_FACTORY_IMPL)
  @tf = TransformerFactory.newInstance
  raise Exception.new("\n*** *******\n*** ERROR loading saxon into jruby.\n*** This error may be caused by missing Saxon jars in jruby lib directory\n*** *******") if @tf.nil?
end

Instance Method Details

#nameObject



41
42
43
# File 'lib/ontomde-core/xslt.rb', line 41

def name
		return "jruby/saxon"
end

#transform(xslt, infile, outfile) ⇒ Object



37
38
39
40
# File 'lib/ontomde-core/xslt.rb', line 37

def transform(xslt,infile,outfile)
  transformer = @tf.newTransformer(StreamSource.new(xslt))
  transformer.transform(StreamSource.new(infile), StreamResult.new(outfile))
end