libxslt-ruby 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,142 +1,164 @@
1
- = libxslt-ruby
2
-
3
- == Overview
4
-
5
- The libxslt gem provides Ruby language bindings for GNOME's Libxslt
6
- toolkit. It is free software, released under the MIT License.
7
-
8
-
9
- == Requirements
10
-
11
- libxslt-ruby requires Ruby 1.8.4 or higher. It is dependent on
12
- the following libraries to function properly:
13
-
14
- * libm (math routines: very standard)
15
- * libz (zlib)
16
- * libiconv
17
- * libxml2
18
- * libxslt
19
- * libxml-ruby bindings
20
-
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.
24
-
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.
31
-
32
-
33
- == INSTALLATION
34
-
35
- The easiest way to install libxslt-ruby is via Ruby Gems. To install:
36
-
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
-
55
- Given an XML file like:
56
-
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-14 21:23:19 -0600 (Mon, 14 Jul 2008) $</date>
69
- <id>$Id: README 94 2008-07-15 03:23:19Z 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>
113
-
114
- We can easily transform the XML with the following ruby code:
115
-
116
- require 'libxslt'
117
-
118
- # Create a new XSL Transform
119
- stylesheet_doc = XML::Document.file('files/fuzface.xsl')
120
- stylesheet = LibXSLT::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
1
+ = libxslt-ruby
2
+
3
+ == Overview
4
+
5
+ The libxslt gem provides Ruby language bindings for GNOME's Libxslt
6
+ toolkit. It is free software, released under the MIT License.
7
+
8
+
9
+ == Requirements
10
+
11
+ libxslt-ruby requires Ruby 1.8.4 or higher. It is dependent on
12
+ the following libraries to function properly:
13
+
14
+ * libm (math routines: very standard)
15
+ * libz (zlib)
16
+ * libiconv
17
+ * libxml2
18
+ * libxslt
19
+ * libxml-ruby bindings
20
+
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.
24
+
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.
31
+
32
+
33
+ == INSTALLATION
34
+
35
+ The easiest way to install libxslt-ruby is via Ruby Gems. To install:
36
+
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.11 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
+
45
+ The Windows binaries are biult with MingW. The gem also includes
46
+ a Microsoft VC++ 2005 solution. If you wish to run a debug version
47
+ of libxml-ruby on Windows, then it is highly recommended
48
+ you use VC++.
49
+
50
+
51
+ == USAGE
52
+
53
+ For in-depth information about using libxslt-ruby please refer
54
+ to its online Rdoc documentation.
55
+
56
+ All libxslt classes are in the LibXSLT::XSLT module. The simplest
57
+ way to use libxslt is to require 'xslt'. This will mixin the
58
+ LibXML and LibXSLT modules into the global namespace, allowing you to
59
+ write code like this:
60
+
61
+ require 'xslt'
62
+ document = XML::Document.new
63
+ stylesheett = XSLT::Stylesheet.new(document)
64
+
65
+ If you prefer not to add the LibXSLT module to the global namepace, then
66
+ write your code like this:
67
+
68
+ require 'libxslt'
69
+
70
+ class MyClass
71
+ def some_method
72
+ document = LibXML::XML::Document.new
73
+ stylesheett = LibXSLT::XSLT::Stylesheet.new(document)
74
+ end
75
+ end
76
+
77
+ Given an XML file like:
78
+
79
+ <?xml version="1.0" encoding="UTF-8"?>
80
+ <?xml-stylesheet href="fuzface.xsl" type="text/xsl"?>
81
+
82
+ <commentary>
83
+ <meta>
84
+ <author>
85
+ <first_name>Sean</first_name>
86
+ <last_name>Chittenden</last_name>
87
+ <email>sean@chittenden.org</email>
88
+ </author>
89
+ <version>$Version$</version>
90
+ <date>$Date: 2008-07-21 20:44:12 -0600 (Mon, 21 Jul 2008) $</date>
91
+ <id>$Id: README 109 2008-07-22 02:44:12Z cfis $</id> <title>Fuzface...</title>
92
+ <subtitle>The Internet's a big place and here's some proof...</subtitle>
93
+ </meta>
94
+
95
+ <body>
96
+ <para>
97
+ I think it's a tragedy that I'm going to start off my new
98
+ commentary by talking about facial hair and the Internet.
99
+ Something about that just screams pathetic, but whatever: it's
100
+ humor and that's life.
101
+ </para>
102
+ </body>
103
+ </commentary>
104
+
105
+ And an XSLT file like this:
106
+
107
+ <?xml version="1.0" ?>
108
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
109
+ <xsl:template match="/">
110
+ <xsl:element name="html">
111
+ <xsl:element name="head">
112
+ <xsl:element name="title">Ramblings - <xsl:value-of select="commentary/meta/title" /> - <xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
113
+ </xsl:element>
114
+
115
+ <xsl:element name="body">
116
+ <xsl:element name="h1"><xsl:value-of select="commentary/meta/title" /></xsl:element>
117
+ <xsl:element name="h3"><xsl:value-of select="commentary/meta/subtitle" /></xsl:element>
118
+ By: <xsl:value-of select="commentary/meta/author/first_name" /> <xsl:value-of select="commentary/meta/author/last_name" /><xsl:element name="br" />
119
+ Date: <xsl:value-of select="commentary/meta/date" /><xsl:element name="br" />
120
+
121
+ <xsl:for-each select="./commentary/body">
122
+ <xsl:apply-templates />
123
+ </xsl:for-each>
124
+
125
+ </xsl:element>
126
+ </xsl:element>
127
+ </xsl:template>
128
+
129
+ <xsl:template match="para">
130
+ <xsl:element name="p">
131
+ <xsl:value-of select="." />
132
+ </xsl:element>
133
+ </xsl:template>
134
+ </xsl:stylesheet>
135
+
136
+ We can easily transform the XML with the following ruby code:
137
+
138
+ require 'xslt'
139
+
140
+ # Create a new XSL Transform
141
+ stylesheet_doc = XML::Document.file('files/fuzface.xsl')
142
+ stylesheet = LibXSLT::Stylesheet.new(stylesheet_doc)
143
+
144
+ # Transform a xml document
145
+ xml_doc = XML::Document.file('files/fuzface.xml')
146
+ result = stylesheet.apply(xml_doc)
147
+
148
+ You can then print, save or manipulate the returned document.
149
+
150
+ == License
151
+
152
+ See LICENSE for license information.
153
+
154
+ == DOCUMENTATION
155
+
156
+ RDoc comments are included - run 'rake doc' to generate documentation.
157
+ You can find the latest documentation at:
158
+
159
+ * http://libxsl.rubyforge.org/
160
+
161
+ == MORE INFORMATION
162
+
163
+ For more information please refer to the documentation. If you have any
142
164
  questions, please send email to libxml-devel@rubyforge.org.
data/Rakefile ADDED
@@ -0,0 +1,129 @@
1
+ require 'rubygems'
2
+ require 'date'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/testtask'
6
+ require 'date'
7
+
8
+ # ------- Default Package ----------
9
+ FILES = FileList[
10
+ 'Rakefile',
11
+ 'README',
12
+ 'LICENSE',
13
+ 'setup.rb',
14
+ 'doc/**/*',
15
+ 'lib/**/*',
16
+ 'ext/libxslt/*.h',
17
+ 'ext/libxslt/*.c',
18
+ 'ext/mingw/Rakefile',
19
+ 'ext/vc/*.sln',
20
+ 'ext/vc/*.vcproj',
21
+ 'tests/**/*'
22
+ ]
23
+
24
+ # Default GEM Specification
25
+ default_spec = Gem::Specification.new do |spec|
26
+ spec.name = "libxslt-ruby"
27
+
28
+ spec.homepage = "http://libxslt.rubyforge.org/"
29
+ spec.summary = "Ruby libxslt bindings"
30
+ spec.description = <<-EOF
31
+ The Libxslt-Ruby project provides Ruby language bindings for the GNOME
32
+ XSLT C library. It is free software, released under the MIT License.
33
+ EOF
34
+
35
+ # Determine the current version of the software
36
+ spec.version =
37
+ if File.read('ext/libxslt/version.h') =~ /\s*RUBY_LIBXSLT_VERSION\s*['"](\d.+)['"]/
38
+ CURRENT_VERSION = $1
39
+ else
40
+ CURRENT_VERSION = "0.0.0"
41
+ end
42
+
43
+ spec.author = "Charlie Savage"
44
+ spec.email = "libxml-devel@rubyforge.org"
45
+ spec.add_dependency('libxml-ruby','>=0.8.2')
46
+ spec.platform = Gem::Platform::RUBY
47
+ spec.require_paths = ["lib", "ext/libxslt"]
48
+
49
+ spec.bindir = "bin"
50
+ spec.extensions = ["ext/libxslt/extconf.rb"]
51
+ spec.files = FILES.to_a
52
+ spec.test_files = Dir.glob("test/tc_*.rb")
53
+
54
+ spec.required_ruby_version = '>= 1.8.4'
55
+ spec.date = DateTime.now
56
+ spec.rubyforge_project = 'libxslt-ruby'
57
+
58
+ spec.has_rdoc = true
59
+ end
60
+
61
+ # Rake task to build the default package
62
+ Rake::GemPackageTask.new(default_spec) do |pkg|
63
+ pkg.package_dir = 'admin/pkg'
64
+ pkg.need_tar = true
65
+ pkg.need_zip = true
66
+ end
67
+
68
+ # ------- Windows Package ----------
69
+ binaries = (FileList['ext/mingw/*.so',
70
+ 'ext/mingw/*.dll'])
71
+
72
+ # Windows specification
73
+ win_spec = default_spec.clone
74
+ win_spec.extensions = []
75
+ win_spec.platform = Gem::Platform::CURRENT
76
+ win_spec.files += binaries.map {|binaryname| "lib/#{File.basename(binaryname)}"}
77
+
78
+ desc "Create Windows Gem"
79
+ task :create_win32_gem do
80
+ # Copy the win32 extension built by MingW - easier to install
81
+ # since there are no dependencies of msvcr80.dll
82
+ current_dir = File.expand_path(File.dirname(__FILE__))
83
+
84
+ binaries.each do |binaryname|
85
+ target = File.join(current_dir, 'lib', File.basename(binaryname))
86
+ cp(binaryname, target)
87
+ end
88
+
89
+ # Create the gem, then move it to pkg
90
+ Gem::Builder.new(win_spec).build
91
+ gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
92
+ mv(gem_file, "admin/pkg/#{gem_file}")
93
+
94
+ # Remove win extension from top level directory
95
+ binaries.each do |binaryname|
96
+ target = File.join(current_dir, 'lib', File.basename(binaryname))
97
+ rm(target)
98
+ end
99
+ end
100
+
101
+ # --------- RDoc Documentation ------
102
+ desc "Generate rdoc documentation"
103
+ Rake::RDocTask.new("rdoc") do |rdoc|
104
+ rdoc.rdoc_dir = 'doc'
105
+ rdoc.title = "libxml-xslt"
106
+ # Show source inline with line numbers
107
+ rdoc.options << "--inline-source" << "--line-numbers"
108
+ # Make the readme file the start page for the generated html
109
+ rdoc.options << '--main' << 'README'
110
+ rdoc.rdoc_files.include('doc/*.rdoc',
111
+ 'ext/**/*.c',
112
+ 'lib/**/*.rb',
113
+ 'CHANGES',
114
+ 'README',
115
+ 'LICENSE')
116
+ end
117
+
118
+ task :package => :rdoc
119
+ task :package => :create_win32_gem
120
+ task :default => :package
121
+
122
+ Rake::TestTask.new do |t|
123
+ t.libs << "test"
124
+ t.libs << "ext"
125
+ end
126
+
127
+ if not RUBY_PLATFORM.match(/mswin32/i)
128
+ Rake::Task[:test].prerequisites << :extensions
129
+ end
@@ -80,6 +80,12 @@
80
80
 
81
81
  <div id="contextContent">
82
82
 
83
+ <div id="description">
84
+ <p>
85
+ :nodoc:
86
+ </p>
87
+
88
+ </div>
83
89
 
84
90
 
85
91
  </div>
@@ -74,19 +74,8 @@
74
74
 
75
75
  <div id="description">
76
76
  <p>
77
- The libxslt gem provides Ruby language bindings for GNOME&#8217;s Libxslt
78
- toolkit. It is free software, released under the MIT License.
77
+ :nodoc:
79
78
  </p>
80
- <p>
81
- Using the bindings is straightforward:
82
- </p>
83
- <pre>
84
- stylesheet_doc = XML::Document.file('stylesheet_file')
85
- stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
86
-
87
- xml_doc = XML::Document.file('xml_file')
88
- result = stylesheet.apply(xml_doc)
89
- </pre>
90
79
 
91
80
  </div>
92
81