libxml-ruby 4.1.2 → 6.0.0

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.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/{HISTORY → CHANGELOG.md} +875 -887
  3. data/LICENSE +20 -20
  4. data/README.md +67 -0
  5. data/Rakefile +77 -98
  6. data/ext/libxml/extconf.rb +39 -20
  7. data/ext/libxml/libxml.c +67 -79
  8. data/ext/libxml/ruby_libxml.h +43 -44
  9. data/ext/libxml/ruby_xml.c +556 -899
  10. data/ext/libxml/ruby_xml.h +9 -10
  11. data/ext/libxml/ruby_xml_attr.c +338 -333
  12. data/ext/libxml/ruby_xml_attr.h +13 -12
  13. data/ext/libxml/ruby_xml_attr_decl.c +19 -12
  14. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  15. data/ext/libxml/ruby_xml_attributes.c +18 -9
  16. data/ext/libxml/ruby_xml_attributes.h +17 -15
  17. data/ext/libxml/ruby_xml_document.c +1142 -1129
  18. data/ext/libxml/ruby_xml_document.h +12 -11
  19. data/ext/libxml/ruby_xml_dtd.c +287 -248
  20. data/ext/libxml/ruby_xml_dtd.h +10 -9
  21. data/ext/libxml/ruby_xml_encoding.c +250 -250
  22. data/ext/libxml/ruby_xml_encoding.h +20 -18
  23. data/ext/libxml/ruby_xml_error.c +1003 -996
  24. data/ext/libxml/ruby_xml_error.h +14 -14
  25. data/ext/libxml/ruby_xml_html_parser.c +91 -91
  26. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  27. data/ext/libxml/ruby_xml_html_parser_context.c +364 -337
  28. data/ext/libxml/ruby_xml_html_parser_context.h +11 -10
  29. data/ext/libxml/ruby_xml_html_parser_options.c +48 -48
  30. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  31. data/ext/libxml/ruby_xml_input_cbg.c +216 -188
  32. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  33. data/ext/libxml/ruby_xml_io.c +49 -47
  34. data/ext/libxml/ruby_xml_io.h +10 -10
  35. data/ext/libxml/ruby_xml_namespace.c +159 -154
  36. data/ext/libxml/ruby_xml_namespace.h +11 -10
  37. data/ext/libxml/ruby_xml_namespaces.c +313 -293
  38. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  39. data/ext/libxml/ruby_xml_node.c +1433 -1398
  40. data/ext/libxml/ruby_xml_node.h +15 -13
  41. data/ext/libxml/ruby_xml_parser.c +91 -91
  42. data/ext/libxml/ruby_xml_parser.h +10 -10
  43. data/ext/libxml/ruby_xml_parser_context.c +1016 -1001
  44. data/ext/libxml/ruby_xml_parser_context.h +11 -10
  45. data/ext/libxml/ruby_xml_parser_options.c +74 -66
  46. data/ext/libxml/ruby_xml_parser_options.h +10 -10
  47. data/ext/libxml/ruby_xml_reader.c +40 -31
  48. data/ext/libxml/ruby_xml_reader.h +14 -14
  49. data/ext/libxml/ruby_xml_registry.c +31 -0
  50. data/ext/libxml/ruby_xml_registry.h +22 -0
  51. data/ext/libxml/ruby_xml_relaxng.c +21 -5
  52. data/ext/libxml/ruby_xml_relaxng.h +9 -8
  53. data/ext/libxml/ruby_xml_sax2_handler.c +326 -326
  54. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  55. data/ext/libxml/ruby_xml_sax_parser.c +108 -116
  56. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  57. data/ext/libxml/ruby_xml_schema.c +22 -15
  58. data/ext/libxml/ruby_xml_schema.h +26 -25
  59. data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
  60. data/ext/libxml/ruby_xml_schema_attribute.h +37 -37
  61. data/ext/libxml/ruby_xml_schema_element.c +8 -8
  62. data/ext/libxml/ruby_xml_schema_element.h +11 -11
  63. data/ext/libxml/ruby_xml_schema_facet.c +50 -50
  64. data/ext/libxml/ruby_xml_schema_facet.h +9 -9
  65. data/ext/libxml/ruby_xml_schema_type.c +12 -19
  66. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  67. data/ext/libxml/ruby_xml_version.h +9 -9
  68. data/ext/libxml/ruby_xml_writer.c +183 -185
  69. data/ext/libxml/ruby_xml_writer.h +6 -6
  70. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  71. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  72. data/ext/libxml/ruby_xml_xpath.c +195 -195
  73. data/ext/libxml/ruby_xml_xpath.h +15 -15
  74. data/ext/libxml/ruby_xml_xpath_context.c +408 -362
  75. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  76. data/ext/libxml/ruby_xml_xpath_expression.c +12 -6
  77. data/ext/libxml/ruby_xml_xpath_expression.h +11 -10
  78. data/ext/libxml/ruby_xml_xpath_object.c +69 -54
  79. data/ext/libxml/ruby_xml_xpath_object.h +19 -17
  80. data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
  81. data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
  82. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  83. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  84. data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
  85. data/lib/libxml/attr.rb +122 -122
  86. data/lib/libxml/attr_decl.rb +80 -80
  87. data/lib/libxml/attributes.rb +13 -13
  88. data/lib/libxml/document.rb +165 -194
  89. data/lib/libxml/error.rb +122 -95
  90. data/lib/libxml/html_parser.rb +80 -96
  91. data/lib/libxml/namespace.rb +61 -61
  92. data/lib/libxml/namespaces.rb +37 -37
  93. data/lib/libxml/node.rb +321 -323
  94. data/lib/libxml/parser.rb +94 -100
  95. data/lib/libxml/sax_callbacks.rb +179 -179
  96. data/lib/libxml/sax_parser.rb +40 -40
  97. data/lib/libxml/schema/attribute.rb +27 -19
  98. data/lib/libxml/schema/element.rb +20 -0
  99. data/lib/libxml/schema/type.rb +44 -21
  100. data/lib/libxml/schema.rb +47 -47
  101. data/lib/libxml/tree.rb +28 -28
  102. data/lib/libxml-ruby.rb +30 -30
  103. data/libxml-ruby.gemspec +46 -48
  104. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  105. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  106. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  107. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  108. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  109. data/test/c14n/result/with-comments/example-1 +5 -5
  110. data/test/c14n/result/with-comments/example-2 +10 -10
  111. data/test/c14n/result/with-comments/example-3 +13 -13
  112. data/test/c14n/result/with-comments/example-4 +8 -8
  113. data/test/c14n/result/with-comments/example-5 +3 -3
  114. data/test/c14n/result/without-comments/example-1 +3 -3
  115. data/test/c14n/result/without-comments/example-2 +10 -10
  116. data/test/c14n/result/without-comments/example-3 +13 -13
  117. data/test/c14n/result/without-comments/example-4 +8 -8
  118. data/test/c14n/result/without-comments/example-5 +2 -2
  119. data/test/test_attr.rb +179 -180
  120. data/test/test_attr_decl.rb +131 -131
  121. data/test/test_attributes.rb +135 -135
  122. data/test/test_canonicalize.rb +122 -120
  123. data/test/test_document.rb +138 -132
  124. data/test/test_document_write.rb +142 -145
  125. data/test/test_dtd.rb +134 -129
  126. data/test/test_encoding.rb +126 -129
  127. data/test/test_encoding_sax.rb +114 -114
  128. data/test/test_error.rb +197 -194
  129. data/test/test_helper.rb +21 -13
  130. data/test/test_html_parser.rb +166 -162
  131. data/test/test_html_parser_context.rb +22 -22
  132. data/test/test_input_callbacks.rb +36 -0
  133. data/test/test_namespace.rb +58 -60
  134. data/test/test_namespaces.rb +200 -200
  135. data/test/test_node.rb +251 -237
  136. data/test/test_node_cdata.rb +50 -50
  137. data/test/test_node_comment.rb +32 -32
  138. data/test/test_node_copy.rb +40 -40
  139. data/test/test_node_edit.rb +176 -158
  140. data/test/test_node_pi.rb +37 -37
  141. data/test/test_node_text.rb +69 -69
  142. data/test/test_node_write.rb +93 -96
  143. data/test/test_node_xlink.rb +28 -28
  144. data/test/test_parser.rb +297 -324
  145. data/test/test_parser_context.rb +198 -198
  146. data/test/test_properties.rb +38 -38
  147. data/test/test_reader.rb +413 -364
  148. data/test/test_relaxng.rb +59 -53
  149. data/test/test_sax_parser.rb +345 -326
  150. data/test/test_schema.rb +28 -0
  151. data/test/test_traversal.rb +152 -152
  152. data/test/test_writer.rb +469 -468
  153. data/test/test_xinclude.rb +20 -20
  154. data/test/test_xml.rb +164 -267
  155. data/test/test_xpath.rb +244 -244
  156. data/test/test_xpath_context.rb +87 -87
  157. data/test/test_xpath_expression.rb +37 -37
  158. metadata +49 -31
  159. data/README.rdoc +0 -217
  160. data/ext/libxml/extconf.h +0 -3
  161. data/ext/libxml/ruby_xml_cbg.c +0 -85
  162. data/lib/libxml/hpricot.rb +0 -78
  163. data/lib/libxml.rb +0 -5
  164. data/lib/xml/libxml.rb +0 -10
  165. data/lib/xml.rb +0 -14
  166. data/script/benchmark/depixelate +0 -634
  167. data/script/benchmark/hamlet.xml +0 -9055
  168. data/script/benchmark/parsecount +0 -170
  169. data/script/benchmark/sock_entries.xml +0 -507
  170. data/script/benchmark/throughput +0 -41
  171. data/script/test +0 -6
  172. data/test/test_deprecated_require.rb +0 -12
@@ -1,37 +1,37 @@
1
- # encoding: UTF-8
2
-
3
- require_relative './test_helper'
4
-
5
-
6
- class TestXPathExpression < Minitest::Test
7
- def setup
8
- xp = LibXML::XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
9
- @doc = xp.parse
10
- end
11
-
12
- def teardown
13
- @doc = nil
14
- end
15
-
16
- def test_nodes
17
- expr = LibXML::XML::XPath::Expression.compile('/ruby_array/fixnum')
18
- set = @doc.find(expr)
19
- assert_instance_of(LibXML::XML::XPath::Object, set)
20
- assert_equal(2, set.size)
21
- end
22
-
23
- def test_find_class
24
- expr = LibXML::XML::XPath::Expression.new('/ruby_array/fixnum')
25
- set = @doc.find(expr)
26
- assert_instance_of(LibXML::XML::XPath::Object, set)
27
- assert_equal(2, set.size)
28
- end
29
-
30
- def test_find_invalid
31
- error = assert_raises(TypeError) do
32
- @doc.find(999)
33
- end
34
- assert_equal('Argument should be an instance of a String or XPath::Expression',
35
- error.to_s)
36
- end
37
- end
1
+ # encoding: UTF-8
2
+
3
+ require_relative './test_helper'
4
+
5
+
6
+ class TestXPathExpression < Minitest::Test
7
+ def setup
8
+ xp = LibXML::XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
9
+ @doc = xp.parse
10
+ end
11
+
12
+ def teardown
13
+ @doc = nil
14
+ end
15
+
16
+ def test_nodes
17
+ expr = LibXML::XML::XPath::Expression.compile('/ruby_array/fixnum')
18
+ set = @doc.find(expr)
19
+ assert_instance_of(LibXML::XML::XPath::Object, set)
20
+ assert_equal(2, set.size)
21
+ end
22
+
23
+ def test_find_class
24
+ expr = LibXML::XML::XPath::Expression.new('/ruby_array/fixnum')
25
+ set = @doc.find(expr)
26
+ assert_instance_of(LibXML::XML::XPath::Object, set)
27
+ assert_equal(2, set.size)
28
+ end
29
+
30
+ def test_find_invalid
31
+ error = assert_raises(TypeError) do
32
+ @doc.find(999)
33
+ end
34
+ assert_equal('Argument should be an instance of a String or XPath::Expression',
35
+ error.to_s)
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libxml-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Bamform
@@ -11,11 +11,24 @@ authors:
11
11
  - Anurag Priyam
12
12
  - Charlie Savage
13
13
  - Ryan Johnson
14
- autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
- date: 2023-11-04 00:00:00.000000000 Z
16
+ date: 1980-01-02 00:00:00.000000000 Z
18
17
  dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: logger
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ type: :development
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
19
32
  - !ruby/object:Gem::Dependency
20
33
  name: rake-compiler
21
34
  requirement: !ruby/object:Gem::Requirement
@@ -44,23 +57,33 @@ dependencies:
44
57
  - - ">="
45
58
  - !ruby/object:Gem::Version
46
59
  version: '0'
47
- description: |2
48
- The Libxml-Ruby project provides Ruby language bindings for the GNOME
49
- Libxml2 XML toolkit. It is free software, released under the MIT License.
50
- Libxml-ruby's primary advantage over REXML is performance - if speed
51
- is your need, these are good libraries to consider, as demonstrated
52
- by the informal benchmark below.
53
- email:
60
+ - !ruby/object:Gem::Dependency
61
+ name: rdoc
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ description: " libxml-Ruby provides Ruby language bindings for libxml2 It is free
75
+ software, \n released under the MIT License. libxml-ruby provides DOM, SAX, Reader,
76
+ and \n Writer APIs along with XPath support and validation via DTD, RelaxNG,
77
+ and XML Schema.\n"
54
78
  executables: []
55
79
  extensions:
56
80
  - ext/libxml/extconf.rb
57
81
  extra_rdoc_files: []
58
82
  files:
59
- - HISTORY
83
+ - CHANGELOG.md
60
84
  - LICENSE
61
- - README.rdoc
85
+ - README.md
62
86
  - Rakefile
63
- - ext/libxml/extconf.h
64
87
  - ext/libxml/extconf.rb
65
88
  - ext/libxml/libxml.c
66
89
  - ext/libxml/libxml_ruby.def
@@ -73,7 +96,6 @@ files:
73
96
  - ext/libxml/ruby_xml_attr_decl.h
74
97
  - ext/libxml/ruby_xml_attributes.c
75
98
  - ext/libxml/ruby_xml_attributes.h
76
- - ext/libxml/ruby_xml_cbg.c
77
99
  - ext/libxml/ruby_xml_document.c
78
100
  - ext/libxml/ruby_xml_document.h
79
101
  - ext/libxml/ruby_xml_dtd.c
@@ -106,6 +128,8 @@ files:
106
128
  - ext/libxml/ruby_xml_parser_options.h
107
129
  - ext/libxml/ruby_xml_reader.c
108
130
  - ext/libxml/ruby_xml_reader.h
131
+ - ext/libxml/ruby_xml_registry.c
132
+ - ext/libxml/ruby_xml_registry.h
109
133
  - ext/libxml/ruby_xml_relaxng.c
110
134
  - ext/libxml/ruby_xml_relaxng.h
111
135
  - ext/libxml/ruby_xml_sax2_handler.c
@@ -136,14 +160,17 @@ files:
136
160
  - ext/libxml/ruby_xml_xpath_object.c
137
161
  - ext/libxml/ruby_xml_xpath_object.h
138
162
  - ext/vc/libxml_ruby.sln
163
+ - ext/vc/libxml_ruby/libxml_ruby.vcxproj
164
+ - ext/xcode/libxml-ruby.xcodeproj/project.pbxproj
165
+ - ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata
166
+ - ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
167
+ - ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme
139
168
  - lib/libxml-ruby.rb
140
- - lib/libxml.rb
141
169
  - lib/libxml/attr.rb
142
170
  - lib/libxml/attr_decl.rb
143
171
  - lib/libxml/attributes.rb
144
172
  - lib/libxml/document.rb
145
173
  - lib/libxml/error.rb
146
- - lib/libxml/hpricot.rb
147
174
  - lib/libxml/html_parser.rb
148
175
  - lib/libxml/namespace.rb
149
176
  - lib/libxml/namespaces.rb
@@ -156,15 +183,7 @@ files:
156
183
  - lib/libxml/schema/element.rb
157
184
  - lib/libxml/schema/type.rb
158
185
  - lib/libxml/tree.rb
159
- - lib/xml.rb
160
- - lib/xml/libxml.rb
161
186
  - libxml-ruby.gemspec
162
- - script/benchmark/depixelate
163
- - script/benchmark/hamlet.xml
164
- - script/benchmark/parsecount
165
- - script/benchmark/sock_entries.xml
166
- - script/benchmark/throughput
167
- - script/test
168
187
  - test/c14n/given/doc.dtd
169
188
  - test/c14n/given/example-1.xml
170
189
  - test/c14n/given/example-2.xml
@@ -220,7 +239,6 @@ files:
220
239
  - test/test_attr_decl.rb
221
240
  - test/test_attributes.rb
222
241
  - test/test_canonicalize.rb
223
- - test/test_deprecated_require.rb
224
242
  - test/test_document.rb
225
243
  - test/test_document_write.rb
226
244
  - test/test_dtd.rb
@@ -230,6 +248,7 @@ files:
230
248
  - test/test_helper.rb
231
249
  - test/test_html_parser.rb
232
250
  - test/test_html_parser_context.rb
251
+ - test/test_input_callbacks.rb
233
252
  - test/test_namespace.rb
234
253
  - test/test_namespaces.rb
235
254
  - test/test_node.rb
@@ -258,8 +277,8 @@ files:
258
277
  homepage: https://xml4r.github.io/libxml-ruby/
259
278
  licenses:
260
279
  - MIT
261
- metadata: {}
262
- post_install_message:
280
+ metadata:
281
+ documentation_uri: https://xml4r.github.io/libxml-ruby/
263
282
  rdoc_options: []
264
283
  require_paths:
265
284
  - lib
@@ -267,15 +286,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
267
286
  requirements:
268
287
  - - ">="
269
288
  - !ruby/object:Gem::Version
270
- version: '2.5'
289
+ version: '3.2'
271
290
  required_rubygems_version: !ruby/object:Gem::Requirement
272
291
  requirements:
273
292
  - - ">="
274
293
  - !ruby/object:Gem::Version
275
294
  version: '0'
276
295
  requirements: []
277
- rubygems_version: 3.4.21
278
- signing_key:
296
+ rubygems_version: 4.0.6
279
297
  specification_version: 4
280
298
  summary: Ruby Bindings for LibXML2
281
299
  test_files:
@@ -283,7 +301,6 @@ test_files:
283
301
  - test/test_attr_decl.rb
284
302
  - test/test_attributes.rb
285
303
  - test/test_canonicalize.rb
286
- - test/test_deprecated_require.rb
287
304
  - test/test_document.rb
288
305
  - test/test_document_write.rb
289
306
  - test/test_dtd.rb
@@ -293,6 +310,7 @@ test_files:
293
310
  - test/test_helper.rb
294
311
  - test/test_html_parser.rb
295
312
  - test/test_html_parser_context.rb
313
+ - test/test_input_callbacks.rb
296
314
  - test/test_namespace.rb
297
315
  - test/test_namespaces.rb
298
316
  - test/test_node.rb
data/README.rdoc DELETED
@@ -1,217 +0,0 @@
1
- = LibXML Ruby
2
-
3
- == Overview
4
- The libxml gem provides Ruby language bindings for GNOME's Libxml2
5
- XML toolkit. It is free software, released under the MIT License.
6
-
7
- We think libxml-ruby is the best XML library for Ruby because:
8
-
9
- * Speed - Its much faster than REXML and Hpricot
10
- * Features - It provides an amazing number of featues
11
- * Conformance - It passes all 1800+ tests from the OASIS XML Tests Suite
12
-
13
- == Requirements
14
- libxml-ruby requires Ruby 1.8.7 or higher. It depends on libxml2 to
15
- function properly. libxml2, in turn, depends on:
16
-
17
- * libm (math routines: very standard)
18
- * libz (zlib)
19
- * libiconv
20
-
21
- If you are running Linux or Unix you'll need a C compiler so the
22
- extension can be compiled when it is installed. If you are running
23
- Windows, then install the x64-mingw32 gem or build it yourself using
24
- Devkit[http://rubyinstaller.org/add-ons/devkit/] or
25
- msys2[https://msys2.github.io/].
26
-
27
- == Installation
28
- The easiest way to install libxml-ruby is via RubyGems. To install:
29
-
30
- <tt>gem install libxml-ruby</tt>
31
-
32
- If the extension compile process cannot find libxml2, you may need to indicate
33
- the location of the libxml2 configuration utility as it is used to find the
34
- required header and include files. (If you need to indicate a location for the
35
- libxml2 library or header files different than reported by <tt>xml2-config</tt>,
36
- see the additional configuration options.)
37
-
38
- This may be done with RubyGems:
39
-
40
- <tt>gem install libxml-ruby -- --with-xml2-dir=/path/to/xml2-config</tt>
41
-
42
- Or bundler:
43
-
44
- <tt>bundle config build.libxml-ruby --with-xml2-config=/path/to/xml2-config</tt>
45
-
46
- <tt>bundle install libxml-ruby</tt>
47
-
48
- If you are running Windows, then install the libxml-ruby-x64-mingw32 gem.
49
- The gem includes prebuilt extensions for Ruby 2.3. These
50
- extensions are built using MinGW64 and libxml2 version 2.9.3,
51
- iconv version 1.14 and zlib version 1.2.8. Note these binaries
52
- are available in the <tt>lib\\libs</tt> directory. To use them, put them
53
- on your <tt>PATH</tt>.
54
-
55
- The gem also includes a Microsoft VC++ 2012 solution and XCode 5 project - these
56
- are very useful for debugging.
57
-
58
- libxml-ruby's source codes lives on GitHub[https://github.com/xml4r/libxml-ruby].
59
-
60
- == Getting Started
61
- Using libxml is easy. First decide what parser you want to use:
62
-
63
- * Generally you'll want to use the LibXML::XML::Parser which provides a tree based API.
64
- * For larger documents that don't fit into memory, or if you prefer an input based API, use the LibXML::XML::Reader.
65
- * To parse HTML files use LibXML::XML::HTMLParser.
66
- * If you are masochistic, then use the LibXML::XML::SaxParser, which provides a callback API.
67
-
68
- Once you have chosen a parser, choose a datasource. Libxml can parse files, strings, URIs
69
- and IO streams. For each data source you can specify an LibXML::XML::Encoding, a base uri and
70
- various parser options. For more information, refer the LibXML::XML::Parser.document,
71
- LibXML::XML::Parser.file, LibXML::XML::Parser.io or LibXML:::XML::Parser.string methods (the
72
- same methods are defined on all four parser classes).
73
-
74
- == Advanced Functionality
75
- Beyond the basics of parsing and processing XML and HTML documents,
76
- libxml provides a wealth of additional functionality.
77
-
78
- Most commonly, you'll want to use its LibXML::XML::XPath support, which makes
79
- it easy to find data inside an XML document. Although not as popular,
80
- LibXML::XML::XPointer provides another API for finding data inside an XML document.
81
-
82
- Often times you'll need to validate data before processing it. For example,
83
- if you accept user generated content submitted over the Web, you'll
84
- want to verify that it does not contain malicious code such as embedded scripts.
85
- This can be done using libxml's powerful set of validators:
86
-
87
- * DTDs (LibXML::XML::Dtd)
88
- * Relax Schemas (LibXML::XML::RelaxNG)
89
- * XML Schema (LibXML::XML::Schema)
90
-
91
- Finally, if you'd like to use XSL Transformations to process data, then install
92
- the {libxslt gem}[https://github.com/xml4r/libxslt-rubygem].
93
-
94
- == Usage
95
- For information about using libxml-ruby please refer to its
96
- documentation[http://xml4r.github.io/libxml-ruby]. Some tutorials are also
97
- available[https://github.com/xml4r/libxml-ruby/wiki].
98
-
99
- All libxml classes are in the LibXML::XML module. The easiest
100
- way to use libxml is to <tt>require 'xml'</tt>. This will mixin
101
- the LibXML module into the global namespace, allowing you to
102
- write code like this:
103
-
104
- require 'xml'
105
- document = XML::Document.new
106
-
107
- However, when creating an application or library you plan to
108
- redistribute, it is best to not add the LibXML module to the global
109
- namespace, in which case you can either write your code like this:
110
-
111
- require 'libxml'
112
- document = LibXML::XML::Document.new
113
-
114
- Or you can utilize a namespace for your own work and include LibXML into it.
115
- For example:
116
-
117
- require 'libxml'
118
-
119
- module MyApplication
120
- include LibXML
121
-
122
- class MyClass
123
- def some_method
124
- document = XML::Document.new
125
- end
126
- end
127
- end
128
-
129
- For simplicity's sake, the documentation uses the xml module in its examples.
130
-
131
- == Threading
132
- libxml-ruby fully supports native, background Ruby threads. This of course
133
- only applies to Ruby 1.9.x and higher since earlier versions of Ruby do not
134
- support native threads.
135
-
136
- == Tests
137
-
138
- To run tests you first need to build the shared libary:
139
-
140
- rake compile
141
-
142
- Once you have build the shared libary, you can then run tests using rake:
143
-
144
- rake test
145
-
146
- +Travis build status: {<img src="https://travis-ci.org/xml4r/libxml-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/xml4r/libxml-ruby]
147
-
148
- == Performance
149
-
150
- In addition to being feature rich and conformation, the main reason
151
- people use libxml-ruby is for performance. Here are the results
152
- of a couple simple benchmarks recently blogged about on the
153
- Web (you can find them in the benchmark directory of the
154
- libxml distribution).
155
-
156
- From http://depixelate.com/2008/4/23/ruby-xml-parsing-benchmarks
157
-
158
- user system total real
159
- libxml 0.032000 0.000000 0.032000 ( 0.031000)
160
- Hpricot 0.640000 0.031000 0.671000 ( 0.890000)
161
- REXML 1.813000 0.047000 1.860000 ( 2.031000)
162
-
163
- From https://svn.concord.org/svn/projects/trunk/common/ruby/xml_benchmarks/
164
-
165
- user system total real
166
- libxml 0.641000 0.031000 0.672000 ( 0.672000)
167
- hpricot 5.359000 0.062000 5.421000 ( 5.516000)
168
- rexml 22.859000 0.047000 22.906000 ( 23.203000)
169
-
170
-
171
- == Documentation
172
- Documentation is available via rdoc, and is installed automatically with the
173
- gem.
174
-
175
- libxml-ruby's {online
176
- documentation}[https://xml4r.github.io/libxml-ruby/rdoc/index.html] is generated
177
- using Hanna, which is a development gem dependency.
178
-
179
- Note that older versions of Rdoc, which ship with Ruby 1.8.x, will report
180
- a number of errors. To avoid them, install Rdoc 2.1 or higher. Once you have
181
- installed the gem, you'll have to disable the version of Rdoc that Ruby 1.8.x
182
- includes. An easy way to do that is rename the directory
183
- <tt>ruby/lib/ruby/1.8/rdoc</tt> to
184
- <tt>ruby/lib/ruby/1.8/rdoc_old</tt>.
185
-
186
- == Support
187
- If you have any questions about using libxml-ruby, please report an issue
188
- on GitHub[https://github.com/xml4r/libxml-ruby/issues].
189
-
190
- == Memory Management
191
- libxml-ruby automatically manages memory associated with the
192
- underlying libxml2 library. The bindings create a one-to-one mapping between
193
- Ruby objects and libxml documents and libxml parent nodes (ie, nodes that do not
194
- have a parent and do not belong to a document). In these cases,
195
- the bindings manage the memory. They do this by installing a free
196
- function and storing a back pointer to the Ruby object from the xmlnode
197
- using the _private member on libxml structures. When the Ruby object
198
- goes out of scope, the underlying libxml structure is freed. Libxml
199
- itself then frees all child nodes (recursively).
200
-
201
- For all other nodes (the vast majority), the bindings create temporary
202
- Ruby objects that get freed once they go out of scope. Thus there can be
203
- more than one Ruby object pointing to the same xml node. To mostly hide
204
- this from a programmer on the Ruby side, the <tt>#eql?</tt> and <tt>#==</tt> methods are
205
- overriden to check if two Ruby objects wrap the same xmlnode. If they do,
206
- then the methods return true. During the mark phase, each of these temporary
207
- objects marks its owning document, thereby keeping the Ruby document object
208
- alive and thus the xmldoc tree.
209
-
210
- In the sweep phase of the garbage collector, or when a program ends,
211
- there is no order to how Ruby objects are freed. In fact, the Ruby document
212
- object is almost always freed before any Ruby objects that wrap child nodes.
213
- However, this is ok because those Ruby objects do not have a free function
214
- and are no longer in scope (since if they were the document would not be freed).
215
-
216
- == License
217
- See LICENSE for license information.
data/ext/libxml/extconf.h DELETED
@@ -1,3 +0,0 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H
3
- #endif
@@ -1,85 +0,0 @@
1
- #include "ruby_libxml.h"
2
- #include <string.h>
3
- #include <libxml/xmlIO.h>
4
-
5
- /*
6
- int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
7
- xmlInputOpenCallback openFunc,
8
- xmlInputReadCallback readFunc,
9
- xmlInputCloseCallback closeFunc);
10
-
11
-
12
- int (*xmlInputMatchCallback) (char const *filename);
13
- void* (*xmlInputOpenCallback) (char const *filename);
14
- int (*xmlInputReadCallback) (void *context,
15
- char *buffer,
16
- int len);
17
- int (*xmlInputCloseCallback) (void *context);
18
- */
19
-
20
- typedef struct deb_doc_context
21
- {
22
- char *buffer;
23
- char *bpos;
24
- int remaining;
25
- } deb_doc_context;
26
-
27
- int deb_Match(char const *filename)
28
- {
29
- fprintf(stderr, "deb_Match: %s\n", filename);
30
- if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6))
31
- {
32
- return (1);
33
- }
34
- return (0);
35
- }
36
-
37
- void* deb_Open(char const *filename)
38
- {
39
- deb_doc_context *deb_doc;
40
- VALUE res;
41
-
42
- deb_doc = (deb_doc_context*) malloc(sizeof(deb_doc_context));
43
-
44
- res = rb_funcall(rb_funcall(rb_mKernel, rb_intern("const_get"), 1,
45
- rb_str_new2("DEBSystem")), rb_intern("document_query"), 1, rb_str_new2(filename));
46
- deb_doc->buffer = strdup(StringValuePtr(res));
47
- //deb_doc->buffer = strdup("<serepes>serepes</serepes>");
48
-
49
- deb_doc->bpos = deb_doc->buffer;
50
- deb_doc->remaining = (int)strlen(deb_doc->buffer);
51
- return deb_doc;
52
- }
53
-
54
- int deb_Read(void *context, char *buffer, int len)
55
- {
56
- deb_doc_context *deb_doc;
57
- int ret_len;
58
- deb_doc = (deb_doc_context*) context;
59
-
60
- if (len >= deb_doc->remaining)
61
- {
62
- ret_len = deb_doc->remaining;
63
- }
64
- else
65
- {
66
- ret_len = len;
67
- }
68
- deb_doc->remaining -= ret_len;
69
- strncpy(buffer, deb_doc->bpos, ret_len);
70
- deb_doc->bpos += ret_len;
71
-
72
- return ret_len;
73
- }
74
-
75
- int deb_Close(void *context)
76
- {
77
- free(((deb_doc_context*) context)->buffer);
78
- free(context);
79
- return 1;
80
- }
81
-
82
- void deb_register_cbg(void)
83
- {
84
- xmlRegisterInputCallbacks(deb_Match, deb_Open, deb_Read, deb_Close);
85
- }
@@ -1,78 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- ## Provide hpricot API for libxml. Provided by Michael Guterl,
4
- ## inspired by http://thebogles.com/blog/an-hpricot-style-interface-to-libxml
5
- #
6
- #class String
7
- # def to_libxml_doc
8
- # xp = XML::Parser.new
9
- # xp.string = self
10
- # xp.parse
11
- # end
12
- #end
13
- #
14
- #module LibXML
15
- # module XML
16
- # class Document
17
- # alias :search :find
18
- # end
19
- #
20
- # class Node
21
- # # find the child node with the given xpath
22
- # def at(xpath)
23
- # self.find_first(xpath)
24
- # end
25
- #
26
- # # find the array of child nodes matching the given xpath
27
- # def search(xpath)
28
- # results = self.find(xpath).to_a
29
- # if block_given?
30
- # results.each do |result|
31
- # yield result
32
- # end
33
- # end
34
- # return results
35
- # end
36
- #
37
- # def /(xpath)
38
- # search(xpath)
39
- # end
40
- #
41
- # # return the inner contents of this node as a string
42
- # def inner_xml
43
- # child.to_s
44
- # end
45
- #
46
- # # alias for inner_xml
47
- # def inner_html
48
- # inner_xml
49
- # end
50
- #
51
- # # return this node and its contents as an xml string
52
- # def to_xml
53
- # self.to_s
54
- # end
55
- #
56
- # # alias for path
57
- # def xpath
58
- # self.path
59
- # end
60
- #
61
- # def find_with_default_ns(xpath_expr, namespace=nil)
62
- # find_base(xpath_expr, namespace || default_namespaces)
63
- # end
64
- #
65
- # def find_first_with_default_ns(xpath_expr, namespace=nil)
66
- # find_first_base(xpath_expr, namespace || default_namespaces)
67
- # end
68
- #
69
- ## alias_method :find_base, :find unless method_defined?(:find_base)
70
- ## alias_method :find, :find_with_default_ns
71
- ## alias_method :find_first_base, :find_first unless method_defined?(:find_first_base)
72
- ## alias_method :find_first, :find_first_with_default_ns
73
- ## alias :child? :first?
74
- ## alias :children? :first?
75
- ## alias :child :first
76
- # end
77
- # end
78
- #end
data/lib/libxml.rb DELETED
@@ -1,5 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # This include is deprecated, use libxml-ruby instead!
4
-
5
- require 'libxml-ruby'
data/lib/xml/libxml.rb DELETED
@@ -1,10 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # This is here for backward compatibility.
4
- #
5
- # TODO: DEPRECATE!
6
-
7
- require 'libxml.rb'
8
-
9
- include LibXML
10
-
data/lib/xml.rb DELETED
@@ -1,14 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # This file loads libxml and adds the LibXML namespace
4
- # to the toplevel for conveneience. The end result
5
- # is to have XML:: universally exposed.
6
- #
7
- # It is recommend that you only load this file for libs
8
- # that do not have their own namespace, eg. administrative
9
- # scripts, personal programs, etc. For other applications
10
- # require 'libxml' instead and include LibXML into your
11
- # app/libs namespace.
12
-
13
- require 'libxml'
14
- include LibXML