= libxslt-ruby
== Overview
The libxslt gem provides Ruby language bindings for GNOME's Libxslt
toolkit. It is free software, released under the MIT License.
== Requirements
libxslt-ruby requires Ruby 1.8.4 or higher. It is dependent on
the following libraries to function properly:
* libm (math routines: very standard)
* libz (zlib)
* libiconv
* libxml2
* libxslt
* libxml-ruby bindings
If you are running Linux or Unix you'll need a C compiler so the extension
can be compiled when it is installed. If you are running Windows, then install the Windows specific RubyGem which
includes an already built extension.
!!!NOTE!!! The libxml-ruby and libxslt-ruby bindings must absolutely, positively,
without a doubt share the same libxml2 library. This is because libxslt modifies
XML documents created by libxml2. If there are two copies of libxml2 on your
system, then when XML documents allocated in copy #1 are manipulated by copy #2,
a segmentation fault will occur. So make sure that your system has only one copy of libxml2
installed.
== INSTALLATION
The easiest way to install libxslt-ruby is via Ruby Gems. To install:
gem install libxslt-ruby
If you are running Windows, make sure to install the Win32 RubyGem which
includes an already built binary file. The binary is built against
libxml2 version 2.6.32, iconv version 1.11 and libxslt version 1.1.24.
Binaries for libxml2 and iconv are provided in the libxml-ruby bindings,
while a binary for libxslt is provided in the libxslt-ruby bindings.
The Windows binaries are biult with MingW. The gem also includes
a Microsoft VC++ 2005 solution. If you wish to run a debug version
of libxml-ruby on Windows, then it is highly recommended
you use VC++.
== USAGE
For in-depth information about using libxslt-ruby please refer
to its online Rdoc documentation.
All libxslt classes are in the LibXSLT::XSLT module. The simplest
way to use libxslt is to require 'xslt'. This will mixin the
LibXML and LibXSLT modules into the global namespace, allowing you to
write code like this:
require 'xslt'
document = XML::Document.new
stylesheett = XSLT::Stylesheet.new(document)
If you prefer not to add the LibXSLT module to the global namepace, then
write your code like this:
require 'libxslt'
class MyClass
def some_method
document = LibXML::XML::Document.new
stylesheett = LibXSLT::XSLT::Stylesheet.new(document)
end
end
Given an XML file like:
Sean
Chittenden
sean@chittenden.org
$Version$
$Date$
$Id$ Fuzface...
The Internet's a big place and here's some proof...
I think it's a tragedy that I'm going to start off my new
commentary by talking about facial hair and the Internet.
Something about that just screams pathetic, but whatever: it's
humor and that's life.
And an XSLT file like this:
Ramblings - -
By:
Date:
We can easily transform the XML with the following ruby code:
require 'xslt'
# Create a new XSL Transform
stylesheet_doc = XML::Document.file('files/fuzface.xsl')
stylesheet = LibXSLT::Stylesheet.new(stylesheet_doc)
# Transform a xml document
xml_doc = XML::Document.file('files/fuzface.xml')
result = stylesheet.apply(xml_doc)
You can then print, save or manipulate the returned document.
== License
See LICENSE for license information.
== DOCUMENTATION
RDoc comments are included - run 'rake doc' to generate documentation.
You can find the latest documentation at:
* http://libxsl.rubyforge.org/
== MORE INFORMATION
For more information please refer to the documentation. If you have any
questions, please send email to libxml-devel@rubyforge.org.