libxslt-ruby 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: 1c764755769750edd73117a1209a5eea3555cc60
4
- data.tar.gz: d876c538407812ef4f4182e8dd97bc831dbdb75f
5
- !binary "U0hBNTEy":
6
- metadata.gz: 782aed33b1170a1a786353e20e9f6374c561da521d027db5cc33d33400060eea7c1300e0b747bc5f783a82b782267840e6b13a14ac7db8bb07aa1347189e3c23
7
- data.tar.gz: f1f7d033f52c7dde655f08ad324b995d232ed2e36d81baf497161c9ad4f24bd3d2ce25a15551a84007422d1ddfb244499ebde21569b616e39d9dddc7a9b3ed85
2
+ SHA1:
3
+ metadata.gz: 20cac3cd9b87d3ca87f9ce387708f6b23360512f
4
+ data.tar.gz: 257a96d52ada6a45bf21a36795044d0a5bcbdcfd
5
+ SHA512:
6
+ metadata.gz: cf874474b474d45ef7da41b4a94d4325f126b32cceae6519289181e867dbd78cbb28c2ab7e569a729baf32b09eb95bb4e04cb1adf15e3d42905e769fbfb0ad70
7
+ data.tar.gz: b26f0ce01488b7946f08c1b1b1c80a28140c3bd67c3363febd761125ca164a3039a306a40f96012326f200eceb7a0b101529e4b7c2e32241ee9dbd95fe15537a
data/CHANGES CHANGED
@@ -1,6 +1,13 @@
1
+ == 1.1.1 / 2014-03-16 Charlie Savage
2
+
3
+ * Adds output and transform methods that respect the <xsl:output> options in stylesheets (Rick Frankel)
4
+ * Update included binaries
5
+ * Update extconf.rb to remove warnings
6
+
1
7
  == 1.1.0 / 2013-01-06 Charlie Savage
2
8
 
3
- * Remove dependency on DL which causes a warning on Ruby 2.0.0
9
+ * Update dependency to latest libxml-ruby version (Charlie Savage)
10
+ * Remove dependency on dl which causes warning in Ruby 2.0.0 (Charlie Savage)
4
11
 
5
12
  == 1.0.9 / 2012-03-17 Charlie Savage
6
13
 
@@ -36,16 +36,12 @@ The easiest way to install libxslt-ruby is via Ruby Gems. To install:
36
36
 
37
37
  <tt>gem install libxslt-ruby</tt>
38
38
 
39
- If you are running Windows, make sure to install the Win32 RubyGem which
39
+ If you are running Windows, make sure to install the Mingw64 RubyGem which
40
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.
41
+ libxml2 version 2.9.1, iconv version 1.14 and libxslt version 1.1.28.
42
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++.
43
+ while binaries for libxslt and libexslt areprovided in the
44
+ libxslt-ruby bindings.
49
45
 
50
46
 
51
47
  == USAGE
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "rubygems"
4
- require "rake/extensiontask"
5
- require "rake/testtask"
3
+ require 'rubygems'
4
+ require 'rake/extensiontask'
5
+ require 'rake/testtask'
6
6
  require 'rdoc/task'
7
- require "yaml"
7
+ require 'yaml'
8
8
 
9
- GEM_NAME = "libxslt-ruby"
10
- SO_NAME = "libxslt_ruby"
9
+ GEM_NAME = 'libxslt-ruby'
10
+ SO_NAME = 'libxslt_ruby'
11
11
 
12
12
  # Read the spec file
13
13
  spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
@@ -22,11 +22,11 @@ Rake::ExtensionTask.new do |ext|
22
22
  ext.name = SO_NAME
23
23
  ext.ext_dir = "ext/libxslt"
24
24
  ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
25
-
26
- ext.config_options << "--with-zlib-dir=C:/MinGW/local"
27
- ext.config_options << "--with-xml2-include=C:/MinGW/local/include/libxml2"
28
- ext.config_options << "--with-xslt-include=C:/MinGW/local/include/libxslt"
29
- ext.config_options << "--with-exslt-include=C:/MinGW/local/include/libexslt"
25
+
26
+ ext.config_options << "--with-zlib-dir=C:/MinGW64/local"
27
+ ext.config_options << "--with-xml2-include=C:/MinGW64/local/include/libxml2"
28
+ ext.config_options << "--with-xslt-include=C:/MinGW64/local/include/libxslt"
29
+ ext.config_options << "--with-exslt-include=C:/MinGW64/local/include/libexslt"
30
30
 
31
31
  ENV.each do |key, val|
32
32
  next unless key =~ /\Awith_(\w+)\z/i
@@ -8,7 +8,7 @@ require 'rbconfig'
8
8
  require 'rubygems'
9
9
  $preload = nil
10
10
  $INCFLAGS << " -I/usr/local/include"
11
- $LIBPATH.push(Config::CONFIG['libdir'])
11
+ $LIBPATH.push(RbConfig::CONFIG['libdir'])
12
12
 
13
13
  def crash(str)
14
14
  print(" extconf failure: %s\n", str)
@@ -131,19 +131,19 @@ paths = ["#{gem_spec.full_gem_path}/lib",
131
131
  "#{gem_spec.full_gem_path}/ext/libxml"]
132
132
 
133
133
  # No need to link xml_ruby on OS X
134
- unless Config::CONFIG['host_os'].match(/darwin/)
134
+ unless RbConfig::CONFIG['host_os'].match(/darwin/)
135
135
  # Hack to make sure ruby library is *after* xml_ruby library
136
136
  $LIBS = "#{$LIBRUBYARG_STATIC} #{$LIBS}"
137
137
 
138
138
  libraries = ["xml_ruby", # Linux
139
139
  ":libxml_ruby.so", # mingw
140
- "libxml_ruby-#{Config::CONFIG["arch"]}"] # mswin
140
+ "libxml_ruby-#{RbConfig::CONFIG["arch"]}"] # mswin
141
141
 
142
- library = libraries.detect do |library|
142
+ libxml_library = libraries.detect do |library|
143
143
  find_library(library, "Init_libxml_ruby", *paths)
144
144
  end
145
145
 
146
- unless library
146
+ unless libxml_library
147
147
  crash(<<-EOL)
148
148
  Need libxml-ruby
149
149
  Please install libxml-ruby or specify the path to the gem via:
@@ -9,6 +9,7 @@ VALUE cXMLDocument;
9
9
  VALUE cLibXSLT;
10
10
  VALUE cXSLT;
11
11
  VALUE eXSLTError;
12
+ VALUE eXMLXSLTStylesheetRequireParsedDoc;
12
13
 
13
14
  /*
14
15
  * Document-class: LibXSLT::XSLT
@@ -58,6 +59,7 @@ Init_libxslt_ruby(void) {
58
59
  rb_define_const(cXSLT, "NAMESPACE_XALAN", rb_str_new2((const char*)XSLT_XALAN_NAMESPACE));
59
60
 
60
61
  eXSLTError = rb_define_class_under(cLibXSLT, "XSLTError", rb_eRuntimeError);
62
+ eXMLXSLTStylesheetRequireParsedDoc = rb_define_class_under(cLibXSLT, "ResultError", rb_eRuntimeError);
61
63
 
62
64
  ruby_init_xslt_stylesheet();
63
65
  ruby_init_exslt();
@@ -32,5 +32,6 @@
32
32
 
33
33
  extern VALUE cXSLT;
34
34
  extern VALUE eXSLTError;
35
+ extern VALUE eXMLXSLTStylesheetRequireParsedDoc;
35
36
 
36
37
  #endif
@@ -3,7 +3,6 @@
3
3
  /* See the LICENSE file for copyright and distribution information. */
4
4
 
5
5
  #include "libxslt.h"
6
-
7
6
  /*
8
7
  * Document-class: LibXSLT::XSLT::Stylesheet
9
8
  *
@@ -254,6 +253,39 @@ ruby_xslt_stylesheet_print(int argc, VALUE *argv, VALUE self) {
254
253
  return(INT2NUM(bytes));
255
254
  }*/
256
255
 
256
+ /* call-seq:
257
+ * stylesheet.output(doc) => string
258
+ *
259
+ * Output an xml document, usually the result of an xslt
260
+ * transformation, and return the result as a string. Output will be
261
+ * done according to the output specification in the xslt
262
+ * stylesheet. Note that this includes the encoding of the string.
263
+ */
264
+ VALUE
265
+ ruby_xslt_stylesheet_output(VALUE self, VALUE document) {
266
+ // FIXME: set string encoding in ruby 1.9?
267
+ xmlDocPtr xdoc;
268
+ xsltStylesheetPtr xstylesheet;
269
+ xmlChar *result = NULL;
270
+ int len = 0, bytes = 0;
271
+ VALUE rresult;
272
+
273
+ if (!rb_obj_is_kind_of(document, cXMLDocument))
274
+ rb_raise(rb_eTypeError, "Must pass in an XML::Document instance.");
275
+
276
+ Data_Get_Struct(document, xmlDoc, xdoc);
277
+ Data_Get_Struct(self, xsltStylesheet, xstylesheet);
278
+
279
+ bytes = xsltSaveResultToString(&result, &len,
280
+ xdoc, xstylesheet);
281
+ if ( bytes == -1 ) {
282
+ rb_raise(rb_eRuntimeError, "error dumping document");
283
+ }
284
+
285
+ rresult=rb_str_new((const char*)result,len);
286
+ xmlFree(result);
287
+ return rresult;
288
+ }
257
289
 
258
290
  #ifdef RDOC_NEVER_DEFINED
259
291
  cLibXSLT = rb_define_module("LibXSLT");
@@ -266,4 +298,5 @@ ruby_init_xslt_stylesheet(void) {
266
298
  rb_define_alloc_func(cXSLTStylesheet, ruby_xslt_stylesheet_alloc);
267
299
  rb_define_method(cXSLTStylesheet, "initialize", ruby_xslt_stylesheet_initialize, 1);
268
300
  rb_define_method(cXSLTStylesheet, "apply", ruby_xslt_stylesheet_apply, -1);
301
+ rb_define_method(cXSLTStylesheet, "output", ruby_xslt_stylesheet_output, 1);
269
302
  }
@@ -1,5 +1,5 @@
1
- #define RUBY_LIBXSLT_VERSION "1.1.0"
1
+ #define RUBY_LIBXSLT_VERSION "1.1.1"
2
2
  #define RUBY_LIBXSLT_VERNUM 1
3
3
  #define RUBY_LIBXSLT_VER_MAJ 1
4
- #define RUBY_LIBXSLT_VER_MIN 0
4
+ #define RUBY_LIBXSLT_VER_MIN 1
5
5
  #define RUBY_LIBXSLT_VER_MIC 0
@@ -13,3 +13,4 @@ end
13
13
 
14
14
  # And add support for deprecated functions
15
15
  require 'libxslt/deprecated'
16
+ require 'libxslt/stylesheet'
@@ -0,0 +1,30 @@
1
+ module LibXSLT
2
+ module XSLT
3
+ class Stylesheet
4
+ # options to be used for parsing stylesheets
5
+ PARSE_OPTIONS = LibXML::XML::Parser::Options::NOCDATA | LibXML::XML::Parser::Options::NOENT
6
+ class << self
7
+ # create a xslt stylesheet from a string
8
+ def string(xml)
9
+ doc = LibXML::XML::Parser.string(xml, :options => PARSE_OPTIONS).parse
10
+ return new(doc)
11
+ end
12
+ # create a xslt stylesheet from a file specified by its filename
13
+ def file(filename)
14
+ doc = LibXML::XML::Parser.file(filename, :options => PARSE_OPTIONS).parse
15
+ return new(doc)
16
+ end
17
+ # create a xslt stylesheet from an io object
18
+ def io(io_object)
19
+ doc = LibXML::XML::Parser.io(io_object, :options => PARSE_OPTIONS).parse
20
+ return new(doc)
21
+ end
22
+ end
23
+ # transform a xml to a string
24
+ def transform(doc)
25
+ return output(apply(doc))
26
+ end
27
+ # transform a xml to a file (specified by an output stream)
28
+ end
29
+ end
30
+ end
@@ -36,7 +36,8 @@ Gem::Specification.new do |spec|
36
36
  'ext/vc/*.vcxproj',
37
37
  'test/**/*'])
38
38
  spec.test_files = Dir.glob("test/test_*.rb")
39
- spec.required_ruby_version = '>= 1.8.6'
39
+ spec.add_development_dependency 'rake-compiler'
40
+ spec.required_ruby_version = '>= 1.9.3'
40
41
  spec.date = DateTime.now
41
42
  spec.rubyforge_project = 'libxslt-ruby'
42
43
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
- require './test_helper'
2
+ require 'test_helper'
3
3
  require 'test/unit'
4
4
 
5
5
  class TestDeprecated < Test::Unit::TestCase
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  require 'test/unit'
3
- require './test_helper'
3
+ require 'test_helper'
4
4
 
5
5
  class TestExslt < Test::Unit::TestCase
6
6
  def setup
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  require 'test/unit'
3
- require './test_helper'
3
+ require 'test_helper'
4
4
 
5
5
  class TextLibXslt < Test::Unit::TestCase
6
6
  def test_constants
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  require 'test/unit'
3
- require './test_helper'
3
+ require 'test_helper'
4
4
 
5
5
  class TestStylesheet < Test::Unit::TestCase
6
6
  def setup
@@ -103,4 +103,112 @@ class TestStylesheet < Test::Unit::TestCase
103
103
  GC.start
104
104
  end
105
105
  end
106
+
107
+ #RAF#
108
+ def test_stylesheet_string
109
+ filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
110
+ style = File.open(filename).readline(nil)
111
+ stylesheet = XSLT::Stylesheet.string(style)
112
+ assert_instance_of(XSLT::Stylesheet, stylesheet)
113
+ end
114
+
115
+ def test_stylesheet_file
116
+ filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
117
+ stylesheet = XSLT::Stylesheet.file(filename)
118
+ assert_instance_of(XSLT::Stylesheet, stylesheet)
119
+ end
120
+
121
+ def test_stylesheet_io
122
+ filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
123
+ stylesheet = XSLT::Stylesheet.io(File.open(filename))
124
+ assert_instance_of(XSLT::Stylesheet, stylesheet)
125
+ end
126
+
127
+ def test_output
128
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
129
+ sdoc = XML::Document.file(filename)
130
+ stylesheet = XSLT::Stylesheet.new(sdoc)
131
+
132
+ rdoc = stylesheet.apply(doc)
133
+
134
+ xml = stylesheet.output(rdoc)
135
+
136
+ # output method is html -> no xml decl, empty tags not closed...
137
+ assert xml =~ /^<html>/
138
+ assert xml =~ /<meta http-equiv="Content-Type" content="text\/html; charset=UTF-8">\n<title>/
139
+ end
140
+
141
+ def test_transform
142
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
143
+ sdoc = XML::Document.file(filename)
144
+ stylesheet = XSLT::Stylesheet.new(sdoc)
145
+
146
+ xml = stylesheet.transform(doc)
147
+
148
+ assert xml =~ /<meta http-equiv="Content-Type" content="text\/html; charset=UTF-8">\n<title>/
149
+ end
150
+
151
+ def test_entities
152
+ style = <<EOF
153
+ <!DOCTYPE xsl:stylesheet [
154
+ <!ENTITY foo 'bar'>
155
+ ]>
156
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
157
+ <xsl:template match="a">
158
+ <out><xsl:text>&foo;</xsl:text>
159
+ <xsl:apply-templates/></out>
160
+ </xsl:template>
161
+ </xsl:stylesheet>
162
+ EOF
163
+
164
+ styledoc = LibXML::XML::Parser.string(style, :options => XSLT::Stylesheet::PARSE_OPTIONS).parse
165
+ stylesheet = XSLT::Stylesheet.new(styledoc)
166
+
167
+ xml = "<!DOCTYPE a [<!ENTITY bla 'fasel'>]><a>&bla;</a>"
168
+ doc = XML::Parser.string(xml, :options => XSLT::Stylesheet::PARSE_OPTIONS).parse
169
+
170
+ out = stylesheet.apply( doc )
171
+ dump = stylesheet.output( out )
172
+ assert_match( /<out>barfasel<\/out>/, dump)
173
+
174
+ # no entity replacement in document
175
+ doc = XML::Parser.string(xml, :options => 0).parse
176
+ out = stylesheet.apply( doc )
177
+ dump = stylesheet.output( out )
178
+
179
+ assert_match(/<out>bar<\/out>/, dump) # entity content is missing
180
+
181
+ # note: having entities in your stylesheet that are not replaced during
182
+ # parse, will crash libxslt (segfault)
183
+ # seems to be a libxslt problem; you should not do that anyway
184
+ # styledoc = LibXML::XML::Parser.string(style, : options => 0).parse
185
+ # stylesheet = XSLT::Stylesheet.new(styledoc)
186
+ end
187
+
188
+ def test_cdatasection
189
+ doc = XML::Parser.string("<a/>").parse
190
+
191
+ style = <<EOF
192
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
193
+ <xsl:template match="a">
194
+ <out><xsl:text disable-output-escaping="yes"><![CDATA[<>]]></xsl:text></out>
195
+ </xsl:template>
196
+ </xsl:stylesheet>
197
+ EOF
198
+
199
+ styledoc = LibXML::XML::Parser.string(style, :options => XSLT::Stylesheet::PARSE_OPTIONS).parse
200
+ stylesheet = XSLT::Stylesheet.new(styledoc)
201
+
202
+ out = stylesheet.apply( doc )
203
+ dump = stylesheet.output( out )
204
+ assert_match( /<out><><\/out>/, dump)
205
+
206
+ # without propper parse options (result is wrong from an xml/xslt point of view)
207
+ styledoc = LibXML::XML::Parser.string(style).parse
208
+ stylesheet = XSLT::Stylesheet.new(styledoc)
209
+
210
+ out = stylesheet.apply( doc )
211
+ dump = stylesheet.output( out )
212
+ assert_match( /<out>&lt;&gt;<\/out>/, dump)
213
+ end
106
214
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libxslt-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-01-06 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libxml-ruby
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: |2
28
42
  The Libxslt-Ruby project provides Ruby language bindings for the GNOME
29
43
  XSLT C library. It is free software, released under the MIT License.
@@ -35,23 +49,24 @@ extra_rdoc_files: []
35
49
  files:
36
50
  - CHANGES
37
51
  - LICENSE
38
- - Rakefile
39
52
  - README.rdoc
40
- - libxslt-ruby.gemspec
41
- - setup.rb
42
- - lib/libxslt/deprecated.rb
43
- - lib/libxslt.rb
44
- - lib/xslt.rb
45
- - ext/libxslt/extconf.h
53
+ - Rakefile
54
+ - ext/libxslt/extconf.rb
55
+ - ext/libxslt/libxslt.c
46
56
  - ext/libxslt/libxslt.h
57
+ - ext/libxslt/ruby_exslt.c
47
58
  - ext/libxslt/ruby_exslt.h
59
+ - ext/libxslt/ruby_xslt_stylesheet.c
48
60
  - ext/libxslt/ruby_xslt_stylesheet.h
49
61
  - ext/libxslt/version.h
50
- - ext/libxslt/libxslt.c
51
- - ext/libxslt/ruby_exslt.c
52
- - ext/libxslt/ruby_xslt_stylesheet.c
53
62
  - ext/vc/libxslt_ruby.sln
54
63
  - ext/vc/libxslt_ruby.vcxproj
64
+ - lib/libxslt.rb
65
+ - lib/libxslt/deprecated.rb
66
+ - lib/libxslt/stylesheet.rb
67
+ - lib/xslt.rb
68
+ - libxslt-ruby.gemspec
69
+ - setup.rb
55
70
  - test/files/commentary.dtd
56
71
  - test/files/fuzface.xml
57
72
  - test/files/fuzface.xsl
@@ -64,7 +79,6 @@ files:
64
79
  - test/test_libxslt.rb
65
80
  - test/test_stylesheet.rb
66
81
  - test/test_suite.rb
67
- - ext/libxslt/extconf.rb
68
82
  homepage: http://libxslt.rubyforge.org/
69
83
  licenses: []
70
84
  metadata: {}
@@ -77,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
91
  requirements:
78
92
  - - ">="
79
93
  - !ruby/object:Gem::Version
80
- version: 1.8.6
94
+ version: 1.9.3
81
95
  required_rubygems_version: !ruby/object:Gem::Requirement
82
96
  requirements:
83
97
  - - ">="
@@ -85,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
99
  version: '0'
86
100
  requirements: []
87
101
  rubyforge_project: libxslt-ruby
88
- rubygems_version: 2.0.0.preview3.1
102
+ rubygems_version: 2.2.2
89
103
  signing_key:
90
104
  specification_version: 4
91
105
  summary: Ruby libxslt bindings
@@ -1,8 +0,0 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H
3
- #define HAVE_RUBY_IO_H 1
4
- #define HAVE_ZLIB_H 1
5
- #define HAVE_LIBXML_XMLVERSION_H 1
6
- #define HAVE_XSLT_H 1
7
- #define HAVE_EXSLT_H 1
8
- #endif