<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>File: README</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



  <div id="fileHeader">
    <h1>README</h1>
    <table class="header-table">
    <tr class="top-aligned-row">
      <td><strong>Path:</strong></td>
      <td>README
      </td>
    </tr>
    <tr class="top-aligned-row">
      <td><strong>Last Update:</strong></td>
      <td>Tue Jul 15 15:48:25 Mountain Daylight Time 2008</td>
    </tr>
    </table>
  </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <h1>libxslt-ruby</h1>
<h2>Overview</h2>
<p>
The libxslt gem provides Ruby language bindings for GNOME&#8217;s Libxslt
toolkit. It is free software, released under the MIT License.
</p>
<h2>Requirements</h2>
<p>
libxslt-ruby requires Ruby 1.8.4 or higher. It is dependent on the
following libraries to function properly:
</p>
<ul>
<li>libm (math routines: very standard)

</li>
<li>libz (zlib)

</li>
<li>libiconv

</li>
<li>libxml2

</li>
<li>libxslt

</li>
<li>libxml-ruby bindings

</li>
</ul>
<p>
If you are running Linux or Unix you&#8217;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.
</p>
<p>
!!!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.
</p>
<h2>INSTALLATION</h2>
<p>
The easiest way to install libxslt-ruby is via Ruby Gems. To install:
</p>
<p>
<tt>gem install libxslt-ruby</tt>
</p>
<p>
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.12 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. These binaries should
be put either in the libxslt/lib directory or on the Windows path.
</p>
<p>
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++.
</p>
<h2>USAGE</h2>
<p>
Given an XML file like:
</p>
<pre>
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;?xml-stylesheet href=&quot;fuzface.xsl&quot; type=&quot;text/xsl&quot;?&gt;

  &lt;commentary&gt;
    &lt;meta&gt;
      &lt;author&gt;
        &lt;first_name&gt;Sean&lt;/first_name&gt;
        &lt;last_name&gt;Chittenden&lt;/last_name&gt;
        &lt;email&gt;sean@chittenden.org&lt;/email&gt;
      &lt;/author&gt;
      &lt;version&gt;$Version$&lt;/version&gt;
      &lt;date&gt;$Date: 2008-07-14 21:23:19 -0600 (Mon, 14 Jul 2008) $&lt;/date&gt;
      &lt;id&gt;$Id: README 94 2008-07-15 03:23:19Z cfis $&lt;/id&gt;     &lt;title&gt;Fuzface...&lt;/title&gt;
      &lt;subtitle&gt;The Internet's a big place and here's some proof...&lt;/subtitle&gt;
    &lt;/meta&gt;

    &lt;body&gt;
      &lt;para&gt;
        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.
      &lt;/para&gt;
    &lt;/body&gt;
  &lt;/commentary&gt;
</pre>
<p>
And an <a href="../classes/XSLT.html">XSLT</a> file like this:
</p>
<pre>
  &lt;?xml version=&quot;1.0&quot; ?&gt;
  &lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot;&gt;
  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;xsl:element name=&quot;html&quot;&gt;
      &lt;xsl:element name=&quot;head&quot;&gt;
        &lt;xsl:element name=&quot;title&quot;&gt;Ramblings - &lt;xsl:value-of select=&quot;commentary/meta/title&quot; /&gt; - &lt;xsl:value-of select=&quot;commentary/meta/subtitle&quot; /&gt;&lt;/xsl:element&gt;
      &lt;/xsl:element&gt;

      &lt;xsl:element name=&quot;body&quot;&gt;
        &lt;xsl:element name=&quot;h1&quot;&gt;&lt;xsl:value-of select=&quot;commentary/meta/title&quot; /&gt;&lt;/xsl:element&gt;
        &lt;xsl:element name=&quot;h3&quot;&gt;&lt;xsl:value-of select=&quot;commentary/meta/subtitle&quot; /&gt;&lt;/xsl:element&gt;
        By: &lt;xsl:value-of select=&quot;commentary/meta/author/first_name&quot; /&gt; &lt;xsl:value-of select=&quot;commentary/meta/author/last_name&quot; /&gt;&lt;xsl:element name=&quot;br&quot; /&gt;
        Date: &lt;xsl:value-of select=&quot;commentary/meta/date&quot; /&gt;&lt;xsl:element name=&quot;br&quot; /&gt;

        &lt;xsl:for-each select=&quot;./commentary/body&quot;&gt;
          &lt;xsl:apply-templates /&gt;
        &lt;/xsl:for-each&gt;

      &lt;/xsl:element&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match=&quot;para&quot;&gt;
    &lt;xsl:element name=&quot;p&quot;&gt;
      &lt;xsl:value-of select=&quot;.&quot; /&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
</pre>
<p>
We can easily transform the XML with the following ruby code:
</p>
<pre>
  require 'libxslt'

  # 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)
</pre>
<p>
You can then print, save or manipulate the returned document.
</p>
<h2>License</h2>
<p>
See LICENSE for license information.
</p>
<h2>DOCUMENTATION</h2>
<p>
RDoc comments are included - run &#8216;rake doc&#8217; to generate
documentation. You can find the latest documentation at:
</p>
<ul>
<li><a href="http://libxsl.rubyforge.org">libxsl.rubyforge.org</a>/

</li>
</ul>
<h2>MORE INFORMATION</h2>
<p>
For more information please refer to the documentation. If you have any
questions, please send email to libxml-devel@rubyforge.org.
</p>

    </div>


   </div>


  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>