libxslt-ruby 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +125 -136
- data/doc/classes/XSLT.html +215 -0
- data/doc/classes/XSLT/Stylesheet.html +244 -0
- data/doc/classes/XSLT/TransformContext.html +111 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGES.html +168 -0
- data/doc/files/LICENSE.html +133 -0
- data/doc/files/README.html +269 -0
- data/doc/files/ext/libxslt/libxslt_c.html +101 -0
- data/doc/files/ext/libxslt/ruby_xslt_stylesheet_c.html +101 -0
- data/doc/files/ext/libxslt/ruby_xslt_transform_context_c.html +101 -0
- data/doc/files/lib/deprecated_rb.html +101 -0
- data/doc/files/lib/libxslt_rb.html +110 -0
- data/doc/fr_class_index.html +29 -0
- data/doc/fr_file_index.html +34 -0
- data/doc/fr_method_index.html +28 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/ext/libxslt/libxslt.c +21 -212
- data/ext/libxslt/libxslt.h +0 -17
- data/ext/libxslt/ruby_xslt_stylesheet.c +135 -173
- data/ext/libxslt/ruby_xslt_stylesheet.h +5 -10
- data/ext/libxslt/ruby_xslt_transform_context.c +5 -2
- data/ext/libxslt/version.h +2 -2
- data/lib/deprecated.rb +66 -0
- data/lib/libxslt.rb +1 -0
- data/mingw/libxslt_ruby.so +0 -0
- data/tests/files/commentary.dtd +34 -0
- data/tests/files/fuzface.xml +154 -0
- data/tests/files/fuzface.xsl +4 -0
- data/tests/files/params.xml +2 -0
- data/tests/files/params.xsl +11 -0
- data/tests/files/ramblings.xsl +46 -0
- data/tests/test_deprecated.rb +99 -0
- data/tests/test_libxslt.rb +21 -0
- data/tests/test_stylesheet.rb +64 -0
- data/tests/test_suite.rb +3 -0
- data/vc/libxslt_ruby.sln +1 -1
- data/vc/libxslt_ruby.vcproj +3 -3
- metadata +41 -10
- data/mingw/mingw.rake +0 -36
data/README
CHANGED
@@ -1,153 +1,142 @@
|
|
1
|
-
|
1
|
+
= libxslt-ruby
|
2
2
|
|
3
|
-
|
3
|
+
== Overview
|
4
4
|
|
5
|
-
|
5
|
+
The libxslt gem provides Ruby language bindings for GNOME's Libxslt
|
6
|
+
toolkit. It is free software, released under the MIT License.
|
6
7
|
|
7
|
-
gem install libxsl-ruby
|
8
|
-
|
9
|
-
=== Tarball/zip
|
10
8
|
|
11
|
-
|
12
|
-
$ rake install
|
9
|
+
== Requirements
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
options, after which you can either use Rake for everything or
|
17
|
-
do with make (make && make install).
|
11
|
+
libxslt-ruby requires Ruby 1.8.4 or higher. It is dependent on
|
12
|
+
the following libraries to function properly:
|
18
13
|
|
19
|
-
|
20
|
-
|
14
|
+
* libm (math routines: very standard)
|
15
|
+
* libz (zlib)
|
16
|
+
* libiconv
|
17
|
+
* libxml2
|
18
|
+
* libxslt
|
19
|
+
* libxml-ruby bindings
|
21
20
|
|
22
|
-
|
21
|
+
If you are running Linux or Unix you'll need a C compiler so the extension
|
22
|
+
can be compiled when it is installed. If you are running Windows, then install the Windows specific RubyGem which
|
23
|
+
includes an already built extension.
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
!!!NOTE!!! The libxml-ruby and libxslt-ruby bindings must absolutely, positively,
|
26
|
+
without a doubt share the same libxml2 library. This is because libxslt modifies
|
27
|
+
XML documents created by libxml2. If there are two copies of libxml2 on your
|
28
|
+
system, then when XML documents allocated in copy #1 are manipulated by copy #2,
|
29
|
+
a segmentation fault will occur. So make sure that your system has only one copy of libxml2
|
30
|
+
installed.
|
26
31
|
|
27
|
-
* http://libxsl.rubyforge.org
|
28
32
|
|
29
|
-
==
|
33
|
+
== INSTALLATION
|
30
34
|
|
31
|
-
|
32
|
-
'xml/libxslt'. The following example is an abridged version of that
|
33
|
-
included with the distribution, which you can run with:
|
35
|
+
The easiest way to install libxslt-ruby is via Ruby Gems. To install:
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
<tt>gem install libxslt-ruby</tt>
|
38
|
+
|
39
|
+
If you are running Windows, make sure to install the Win32 RubyGem which
|
40
|
+
includes an already built binary file. The binary is built against
|
41
|
+
libxml2 version 2.6.32, iconv version 1.12 and libxslt version 1.1.24.
|
42
|
+
Binaries for libxml2 and iconv are provided in the libxml-ruby bindings,
|
43
|
+
while a binary for libxslt is provided in the libxslt-ruby bindings.
|
44
|
+
These binaries should be put either in the libxslt/lib directory
|
45
|
+
or on the Windows path.
|
46
|
+
|
47
|
+
The Windows binaries are biult with MingW. The gem also includes
|
48
|
+
a Microsoft VC++ 2005 solution. If you wish to run a debug version
|
49
|
+
of libxml-ruby on Windows, then it is highly recommended
|
50
|
+
you use VC++.
|
51
|
+
|
52
|
+
|
53
|
+
== USAGE
|
54
|
+
|
38
55
|
Given an XML file like:
|
39
56
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
And an XSLT like:
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
57
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
58
|
+
<?xml-stylesheet href="fuzface.xsl" type="text/xsl"?>
|
59
|
+
|
60
|
+
<commentary>
|
61
|
+
<meta>
|
62
|
+
<author>
|
63
|
+
<first_name>Sean</first_name>
|
64
|
+
<last_name>Chittenden</last_name>
|
65
|
+
<email>sean@chittenden.org</email>
|
66
|
+
</author>
|
67
|
+
<version>$Version$</version>
|
68
|
+
<date>$Date: 2008-07-10 00:39:47 -0600 (Thu, 10 Jul 2008) $</date>
|
69
|
+
<id>$Id: README 64 2008-07-10 06:39:47Z cfis $</id> <title>Fuzface...</title>
|
70
|
+
<subtitle>The Internet's a big place and here's some proof...</subtitle>
|
71
|
+
</meta>
|
72
|
+
|
73
|
+
<body>
|
74
|
+
<para>
|
75
|
+
I think it's a tragedy that I'm going to start off my new
|
76
|
+
commentary by talking about facial hair and the Internet.
|
77
|
+
Something about that just screams pathetic, but whatever: it's
|
78
|
+
humor and that's life.
|
79
|
+
</para>
|
80
|
+
</body>
|
81
|
+
</commentary>
|
82
|
+
|
83
|
+
And an XSLT file like this:
|
84
|
+
|
85
|
+
<?xml version="1.0" ?>
|
86
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
87
|
+
<xsl:template match="/">
|
88
|
+
<xsl:element name="html">
|
89
|
+
<xsl:element name="head">
|
90
|
+
<xsl:element name="title">Ramblings - <xsl:value-of select="commentary/meta/title" /> - <xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
|
91
|
+
</xsl:element>
|
92
|
+
|
93
|
+
<xsl:element name="body">
|
94
|
+
<xsl:element name="h1"><xsl:value-of select="commentary/meta/title" /></xsl:element>
|
95
|
+
<xsl:element name="h3"><xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
|
96
|
+
By: <xsl:value-of select="commentary/meta/author/first_name" /> <xsl:value-of select="commentary/meta/author/last_name" /><xsl:element name="br" />
|
97
|
+
Date: <xsl:value-of select="commentary/meta/date" /><xsl:element name="br" />
|
98
|
+
|
99
|
+
<xsl:for-each select="./commentary/body">
|
100
|
+
<xsl:apply-templates />
|
101
|
+
</xsl:for-each>
|
102
|
+
|
103
|
+
</xsl:element>
|
104
|
+
</xsl:element>
|
105
|
+
</xsl:template>
|
106
|
+
|
107
|
+
<xsl:template match="para">
|
108
|
+
<xsl:element name="p">
|
109
|
+
<xsl:value-of select="." />
|
110
|
+
</xsl:element>
|
111
|
+
</xsl:template>
|
112
|
+
</xsl:stylesheet>
|
96
113
|
|
97
114
|
We can easily transform the XML with the following ruby code:
|
98
115
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
<body>
|
127
|
-
<h1>Fuzface...</h1>
|
128
|
-
<h3>The Internet's a big place and here's some proof...</h3>
|
129
|
-
By: SeanChittenden<br>
|
130
|
-
Date: $Date: 2007-08-29 12:18:15 -0600 (Wed, 29 Aug 2007) $<br>
|
131
|
-
<p>
|
132
|
-
I think it's a tragedy that I'm going to start off my new
|
133
|
-
commentary by talking about facial hair and the Internet.
|
134
|
-
Something about that just screams pathetic, but whatever: it's
|
135
|
-
humor and that's life.
|
136
|
-
</p>
|
137
|
-
</body>
|
138
|
-
</html>
|
139
|
-
|
140
|
-
== If you checked out from CVS
|
141
|
-
|
142
|
-
If you checked out the source from CVS, you must install a copy of
|
143
|
-
the current (or matching) libxml-ruby headers in:
|
144
|
-
|
145
|
-
ext/xml/libxml-ruby
|
146
|
-
|
147
|
-
prior to running the above. This can be done via rake, and will
|
148
|
-
happen automatically if ../libxml/ext/xml is found, or the
|
149
|
-
LIBXMLH=/path/to/headers commandline option is supplied.
|
150
|
-
|
151
|
-
# $Id: README 33 2007-08-29 18:18:15Z transami $
|
152
|
-
|
153
|
-
# See the LICENSE file for copyright and distribution information
|
116
|
+
require 'libxslt'
|
117
|
+
|
118
|
+
# Create a new XSL Transform
|
119
|
+
stylesheet_doc = XML::Document.file('files/fuzface.xsl')
|
120
|
+
stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
|
121
|
+
|
122
|
+
# Transform a xml document
|
123
|
+
xml_doc = XML::Document.file('files/fuzface.xml')
|
124
|
+
result = stylesheet.apply(xml_doc)
|
125
|
+
|
126
|
+
You can then print, save or manipulate the returned document.
|
127
|
+
|
128
|
+
== License
|
129
|
+
|
130
|
+
See LICENSE for license information.
|
131
|
+
|
132
|
+
== DOCUMENTATION
|
133
|
+
|
134
|
+
RDoc comments are included - run 'rake doc' to generate documentation.
|
135
|
+
You can find the latest documentation at:
|
136
|
+
|
137
|
+
* http://libxsl.rubyforge.org/
|
138
|
+
|
139
|
+
== MORE INFORMATION
|
140
|
+
|
141
|
+
For more information please refer to the documentation. If you have any
|
142
|
+
questions, please send email to libxml-devel@rubyforge.org.
|
@@ -0,0 +1,215 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: XSLT</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">XSLT</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/ext/libxslt/libxslt_c.html">
|
59
|
+
ext/libxslt/libxslt.c
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../files/ext/libxslt/ruby_xslt_stylesheet_c.html">
|
63
|
+
ext/libxslt/ruby_xslt_stylesheet.c
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/ext/libxslt/ruby_xslt_transform_context_c.html">
|
67
|
+
ext/libxslt/ruby_xslt_transform_context.c
|
68
|
+
</a>
|
69
|
+
<br />
|
70
|
+
</td>
|
71
|
+
</tr>
|
72
|
+
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
The libxslt gem provides Ruby language bindings for GNOME’s Libxslt
|
86
|
+
toolkit. It is free software, released under the MIT License.
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
Using the bindings is straightforward:
|
90
|
+
</p>
|
91
|
+
<pre>
|
92
|
+
stylesheet_doc = XML::Document.file('stylesheet_file')
|
93
|
+
stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
|
94
|
+
|
95
|
+
xml_doc = XML::Document.file('xml_file')
|
96
|
+
result = stylesheet.apply(xml_doc)
|
97
|
+
</pre>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if includes -->
|
109
|
+
|
110
|
+
<div id="section">
|
111
|
+
|
112
|
+
<div id="class-list">
|
113
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
114
|
+
|
115
|
+
Class <a href="XSLT/Stylesheet.html" class="link">XSLT::Stylesheet</a><br />
|
116
|
+
Class <a href="XSLT/TransformContext.html" class="link">XSLT::TransformContext</a><br />
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div id="constants-list">
|
121
|
+
<h3 class="section-bar">Constants</h3>
|
122
|
+
|
123
|
+
<div class="name-list">
|
124
|
+
<table summary="Constants">
|
125
|
+
<tr class="top-aligned-row context-row">
|
126
|
+
<td class="context-item-name">MAX_DEPTH</td>
|
127
|
+
<td>=</td>
|
128
|
+
<td class="context-item-value">INT2NUM(xsltMaxDepth)</td>
|
129
|
+
</tr>
|
130
|
+
<tr class="top-aligned-row context-row">
|
131
|
+
<td class="context-item-name">MAX_SORT</td>
|
132
|
+
<td>=</td>
|
133
|
+
<td class="context-item-value">INT2NUM(XSLT_MAX_SORT)</td>
|
134
|
+
</tr>
|
135
|
+
<tr class="top-aligned-row context-row">
|
136
|
+
<td class="context-item-name">ENGINE_VERSION</td>
|
137
|
+
<td>=</td>
|
138
|
+
<td class="context-item-value">rb_str_new2(xsltEngineVersion)</td>
|
139
|
+
</tr>
|
140
|
+
<tr class="top-aligned-row context-row">
|
141
|
+
<td class="context-item-name">LIBXSLT_VERSION</td>
|
142
|
+
<td>=</td>
|
143
|
+
<td class="context-item-value">INT2NUM(xsltLibxsltVersion)</td>
|
144
|
+
</tr>
|
145
|
+
<tr class="top-aligned-row context-row">
|
146
|
+
<td class="context-item-name">LIBXML_VERSION</td>
|
147
|
+
<td>=</td>
|
148
|
+
<td class="context-item-value">INT2NUM(xsltLibxmlVersion)</td>
|
149
|
+
</tr>
|
150
|
+
<tr class="top-aligned-row context-row">
|
151
|
+
<td class="context-item-name">XSLT_NAMESPACE</td>
|
152
|
+
<td>=</td>
|
153
|
+
<td class="context-item-value">rb_str_new2((const char*)XSLT_NAMESPACE)</td>
|
154
|
+
</tr>
|
155
|
+
<tr class="top-aligned-row context-row">
|
156
|
+
<td class="context-item-name">DEFAULT_VENDOR</td>
|
157
|
+
<td>=</td>
|
158
|
+
<td class="context-item-value">rb_str_new2(XSLT_DEFAULT_VENDOR)</td>
|
159
|
+
</tr>
|
160
|
+
<tr class="top-aligned-row context-row">
|
161
|
+
<td class="context-item-name">DEFAULT_VERSION</td>
|
162
|
+
<td>=</td>
|
163
|
+
<td class="context-item-value">rb_str_new2(XSLT_DEFAULT_VERSION)</td>
|
164
|
+
</tr>
|
165
|
+
<tr class="top-aligned-row context-row">
|
166
|
+
<td class="context-item-name">DEFAULT_URL</td>
|
167
|
+
<td>=</td>
|
168
|
+
<td class="context-item-value">rb_str_new2(XSLT_DEFAULT_URL)</td>
|
169
|
+
</tr>
|
170
|
+
<tr class="top-aligned-row context-row">
|
171
|
+
<td class="context-item-name">NAMESPACE_LIBXSLT</td>
|
172
|
+
<td>=</td>
|
173
|
+
<td class="context-item-value">rb_str_new2((const char*)XSLT_LIBXSLT_NAMESPACE)</td>
|
174
|
+
</tr>
|
175
|
+
<tr class="top-aligned-row context-row">
|
176
|
+
<td class="context-item-name">NAMESPACE_NORM_SAXON</td>
|
177
|
+
<td>=</td>
|
178
|
+
<td class="context-item-value">rb_str_new2((const char*)XSLT_NORM_SAXON_NAMESPACE)</td>
|
179
|
+
</tr>
|
180
|
+
<tr class="top-aligned-row context-row">
|
181
|
+
<td class="context-item-name">NAMESPACE_SAXON</td>
|
182
|
+
<td>=</td>
|
183
|
+
<td class="context-item-value">rb_str_new2((const char*)XSLT_SAXON_NAMESPACE)</td>
|
184
|
+
</tr>
|
185
|
+
<tr class="top-aligned-row context-row">
|
186
|
+
<td class="context-item-name">NAMESPACE_XT</td>
|
187
|
+
<td>=</td>
|
188
|
+
<td class="context-item-value">rb_str_new2((const char*)XSLT_XT_NAMESPACE)</td>
|
189
|
+
</tr>
|
190
|
+
<tr class="top-aligned-row context-row">
|
191
|
+
<td class="context-item-name">NAMESPACE_XALAN</td>
|
192
|
+
<td>=</td>
|
193
|
+
<td class="context-item-value">rb_str_new2((const char*)XSLT_XALAN_NAMESPACE)</td>
|
194
|
+
</tr>
|
195
|
+
</table>
|
196
|
+
</div>
|
197
|
+
</div>
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
<!-- if method_list -->
|
205
|
+
|
206
|
+
|
207
|
+
</div>
|
208
|
+
|
209
|
+
|
210
|
+
<div id="validator-badges">
|
211
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
</body>
|
215
|
+
</html>
|