Project

ruby-xslt

0.03
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Ruby/XSLT is a simple XSLT class based on libxml <http://xmlsoft.org/> and libxslt <http://xmlsoft.org/XSLT/>
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Ruby/XSLT¶ ↑

About¶ ↑

Ruby/XSLT is a simple XSLT class based on libxml <xmlsoft.org/> and libxslt <xmlsoft.org/XSLT/>

Licence¶ ↑

Copyright © 2003-2012 Gregoire Lejeune <gregoire dot lejeune at free dot fr>

Ruby/XSLT is freely distributable according to the terms of the GNU General Public License (see the file ‘COPYING’).

This program is distributed without any warranty. See the file ‘COPYING’ for details.

INSTALLATION¶ ↑

sudo gem install ruby-xslt

or

ruby extconf.rb # see CONFIGURATION for more options
make
make test
make doc
sudo make install

CONFIGURATION¶ ↑

--help                   display this help and exit

--with-xslt-lib=PATH
--with-xslt-include=PATH
--with-xslt-dir=PATH     specify the directory name for the libxslt include 
                         files and/or library 

--disable-error-handler  disables the new error handler 

--disable-exslt          disables libexslt support <http://exslt.org/>

EXAMPLES¶ ↑

Simple example¶ ↑

require 'xml/xslt'

xslt = XML::XSLT.new()
xslt.xml = "text.xml"
xslt.xsl = "test.xsl"

out = xslt.serve()
print out;

REXML support¶ ↑

require 'rexml/document'
require 'xml/xslt'

xslt = XML::XSLT.new()

xslt.xml = REXML::Document.new File.read( "test.xml" )
xslt.xsl = REXML::Document.new File.read( "test.xsl" )

out = xslt.serve()
print out;

XML::Smart support¶ ↑

require 'xml/smart'
require 'xml/xslt'

xslt = XML::XSLT.new()

xslt.xml = XML::Smart.open( "test.xml" )
xslt.xsl = XML::Smart.open( "test.xsl" )

out = xslt.serve()
print out;

Parameters support¶ ↑

require "xml/xslt"

xslt = XML::XSLT.new()
xslt.xsl = "parameter.xsl"
xslt.xml = "test.xml"
xslt.parameters = { "p1" => "the first parameter ...",
                    "p2" => "'and the second one!'" }
xslt.save("test1.html")

xslt.parameters = { "p1" => "Ruby...",
                    "p2" => "'...is cool !'" }
xslt.save("test2.html")

External functions support¶ ↑

require "xml/xslt"

xslt = XML::XSLT.new()
xslt.xsl = "functions.xsl"
xslt.xml = "test.xml"

XML::XSLT.registerExtFunc("http://test.none", "round-trip") do |arg|
  arg
end

XML::XSLT.registerExtFunc("http://test.none", "type") do |arg|
  arg.class.to_s
end

print xslt.serve

Error handling¶ ↑

XML::XSLT.registerErrorHandler { |string| puts string }

xslt = XML::XSLT.new
xslt.xml = "not xml"

This fragment would print:

Entity: line 1: 
parser 
error : 
Start Tag expected, '<' not found
not xml
^