libxml-ruby 5.0.6 → 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 (131) hide show
  1. checksums.yaml +4 -4
  2. data/{HISTORY → CHANGELOG.md} +875 -930
  3. data/LICENSE +20 -20
  4. data/README.md +67 -0
  5. data/Rakefile +13 -34
  6. data/ext/libxml/extconf.rb +34 -20
  7. data/ext/libxml/libxml.c +2 -14
  8. data/ext/libxml/ruby_libxml.h +1 -1
  9. data/ext/libxml/ruby_xml_attr.c +27 -22
  10. data/ext/libxml/ruby_xml_attr.h +1 -0
  11. data/ext/libxml/ruby_xml_attr_decl.c +19 -12
  12. data/ext/libxml/ruby_xml_attributes.c +18 -9
  13. data/ext/libxml/ruby_xml_document.c +111 -98
  14. data/ext/libxml/ruby_xml_document.h +1 -0
  15. data/ext/libxml/ruby_xml_dtd.c +49 -19
  16. data/ext/libxml/ruby_xml_dtd.h +1 -0
  17. data/ext/libxml/ruby_xml_html_parser.c +1 -1
  18. data/ext/libxml/ruby_xml_html_parser_context.c +19 -6
  19. data/ext/libxml/ruby_xml_html_parser_context.h +1 -0
  20. data/ext/libxml/ruby_xml_input_cbg.c +45 -17
  21. data/ext/libxml/ruby_xml_io.c +3 -1
  22. data/ext/libxml/ruby_xml_namespace.c +20 -12
  23. data/ext/libxml/ruby_xml_namespace.h +1 -0
  24. data/ext/libxml/ruby_xml_namespaces.c +40 -20
  25. data/ext/libxml/ruby_xml_node.c +71 -32
  26. data/ext/libxml/ruby_xml_node.h +2 -0
  27. data/ext/libxml/ruby_xml_parser.c +1 -1
  28. data/ext/libxml/ruby_xml_parser_context.c +54 -47
  29. data/ext/libxml/ruby_xml_parser_context.h +1 -0
  30. data/ext/libxml/ruby_xml_reader.c +25 -15
  31. data/ext/libxml/ruby_xml_registry.c +31 -0
  32. data/ext/libxml/ruby_xml_registry.h +22 -0
  33. data/ext/libxml/ruby_xml_relaxng.c +21 -5
  34. data/ext/libxml/ruby_xml_relaxng.h +1 -0
  35. data/ext/libxml/ruby_xml_sax_parser.c +1 -1
  36. data/ext/libxml/ruby_xml_schema.c +18 -11
  37. data/ext/libxml/ruby_xml_schema.h +1 -0
  38. data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
  39. data/ext/libxml/ruby_xml_schema_element.c +8 -8
  40. data/ext/libxml/ruby_xml_schema_facet.c +7 -7
  41. data/ext/libxml/ruby_xml_schema_type.c +12 -19
  42. data/ext/libxml/ruby_xml_version.h +4 -4
  43. data/ext/libxml/ruby_xml_writer.c +18 -6
  44. data/ext/libxml/ruby_xml_xpath.c +2 -2
  45. data/ext/libxml/ruby_xml_xpath.h +1 -1
  46. data/ext/libxml/ruby_xml_xpath_context.c +72 -26
  47. data/ext/libxml/ruby_xml_xpath_expression.c +11 -5
  48. data/ext/libxml/ruby_xml_xpath_expression.h +1 -0
  49. data/ext/libxml/ruby_xml_xpath_object.c +69 -54
  50. data/ext/libxml/ruby_xml_xpath_object.h +3 -1
  51. data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
  52. data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
  53. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  54. data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  55. data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
  56. data/lib/libxml/document.rb +0 -29
  57. data/lib/libxml/error.rb +30 -3
  58. data/lib/libxml/html_parser.rb +0 -16
  59. data/lib/libxml/node.rb +1 -3
  60. data/lib/libxml/parser.rb +0 -8
  61. data/lib/libxml/schema/attribute.rb +27 -19
  62. data/lib/libxml/schema/element.rb +20 -0
  63. data/lib/libxml/schema/type.rb +44 -21
  64. data/lib/libxml/schema.rb +47 -47
  65. data/lib/libxml-ruby.rb +30 -30
  66. data/libxml-ruby.gemspec +12 -16
  67. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  68. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  69. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  70. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  71. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  72. data/test/c14n/result/with-comments/example-1 +5 -5
  73. data/test/c14n/result/with-comments/example-2 +10 -10
  74. data/test/c14n/result/with-comments/example-3 +13 -13
  75. data/test/c14n/result/with-comments/example-4 +8 -8
  76. data/test/c14n/result/with-comments/example-5 +3 -3
  77. data/test/c14n/result/without-comments/example-1 +3 -3
  78. data/test/c14n/result/without-comments/example-2 +10 -10
  79. data/test/c14n/result/without-comments/example-3 +13 -13
  80. data/test/c14n/result/without-comments/example-4 +8 -8
  81. data/test/c14n/result/without-comments/example-5 +2 -2
  82. data/test/test_attr.rb +179 -180
  83. data/test/test_attr_decl.rb +131 -131
  84. data/test/test_attributes.rb +135 -135
  85. data/test/test_canonicalize.rb +122 -120
  86. data/test/test_document.rb +2 -4
  87. data/test/test_dtd.rb +12 -4
  88. data/test/test_encoding_sax.rb +114 -114
  89. data/test/test_error.rb +1 -1
  90. data/test/test_html_parser.rb +6 -2
  91. data/test/test_html_parser_context.rb +22 -22
  92. data/test/test_input_callbacks.rb +36 -0
  93. data/test/test_namespace.rb +1 -1
  94. data/test/test_namespaces.rb +200 -200
  95. data/test/test_node.rb +16 -0
  96. data/test/test_node_cdata.rb +50 -50
  97. data/test/test_node_comment.rb +32 -32
  98. data/test/test_node_copy.rb +40 -40
  99. data/test/test_node_edit.rb +176 -158
  100. data/test/test_node_pi.rb +37 -37
  101. data/test/test_node_text.rb +69 -69
  102. data/test/test_node_xlink.rb +28 -28
  103. data/test/test_parser.rb +5 -41
  104. data/test/test_parser_context.rb +198 -198
  105. data/test/test_properties.rb +38 -38
  106. data/test/test_reader.rb +55 -6
  107. data/test/test_relaxng.rb +59 -53
  108. data/test/test_sax_parser.rb +345 -345
  109. data/test/test_schema.rb +28 -0
  110. data/test/test_traversal.rb +152 -152
  111. data/test/test_writer.rb +0 -31
  112. data/test/test_xinclude.rb +20 -20
  113. data/test/test_xml.rb +3 -7
  114. data/test/test_xpath.rb +244 -244
  115. data/test/test_xpath_context.rb +87 -87
  116. data/test/test_xpath_expression.rb +37 -37
  117. metadata +32 -25
  118. data/README.rdoc +0 -208
  119. data/ext/libxml/extconf.h +0 -4
  120. data/ext/libxml/ruby_xml_cbg.c +0 -85
  121. data/lib/libxml/hpricot.rb +0 -78
  122. data/lib/libxml.rb +0 -5
  123. data/lib/xml/libxml.rb +0 -10
  124. data/lib/xml.rb +0 -14
  125. data/script/benchmark/depixelate +0 -634
  126. data/script/benchmark/hamlet.xml +0 -9055
  127. data/script/benchmark/parsecount +0 -170
  128. data/script/benchmark/sock_entries.xml +0 -507
  129. data/script/benchmark/throughput +0 -41
  130. data/script/test +0 -6
  131. 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: 5.0.6
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Bamform
@@ -13,7 +13,7 @@ authors:
13
13
  - Ryan Johnson
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2026-04-03 00:00:00.000000000 Z
16
+ date: 1980-01-02 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: logger
@@ -57,22 +57,33 @@ dependencies:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
- description: |2
61
- The Libxml-Ruby project provides Ruby language bindings for the GNOME
62
- Libxml2 XML toolkit. It is free software, released under the MIT License.
63
- Libxml-ruby's primary advantage over REXML is performance - if speed
64
- is your need, these are good libraries to consider, as demonstrated
65
- by the informal benchmark below.
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"
66
78
  executables: []
67
79
  extensions:
68
80
  - ext/libxml/extconf.rb
69
81
  extra_rdoc_files: []
70
82
  files:
71
- - HISTORY
83
+ - CHANGELOG.md
72
84
  - LICENSE
73
- - README.rdoc
85
+ - README.md
74
86
  - Rakefile
75
- - ext/libxml/extconf.h
76
87
  - ext/libxml/extconf.rb
77
88
  - ext/libxml/libxml.c
78
89
  - ext/libxml/libxml_ruby.def
@@ -85,7 +96,6 @@ files:
85
96
  - ext/libxml/ruby_xml_attr_decl.h
86
97
  - ext/libxml/ruby_xml_attributes.c
87
98
  - ext/libxml/ruby_xml_attributes.h
88
- - ext/libxml/ruby_xml_cbg.c
89
99
  - ext/libxml/ruby_xml_document.c
90
100
  - ext/libxml/ruby_xml_document.h
91
101
  - ext/libxml/ruby_xml_dtd.c
@@ -118,6 +128,8 @@ files:
118
128
  - ext/libxml/ruby_xml_parser_options.h
119
129
  - ext/libxml/ruby_xml_reader.c
120
130
  - ext/libxml/ruby_xml_reader.h
131
+ - ext/libxml/ruby_xml_registry.c
132
+ - ext/libxml/ruby_xml_registry.h
121
133
  - ext/libxml/ruby_xml_relaxng.c
122
134
  - ext/libxml/ruby_xml_relaxng.h
123
135
  - ext/libxml/ruby_xml_sax2_handler.c
@@ -148,14 +160,17 @@ files:
148
160
  - ext/libxml/ruby_xml_xpath_object.c
149
161
  - ext/libxml/ruby_xml_xpath_object.h
150
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
151
168
  - lib/libxml-ruby.rb
152
- - lib/libxml.rb
153
169
  - lib/libxml/attr.rb
154
170
  - lib/libxml/attr_decl.rb
155
171
  - lib/libxml/attributes.rb
156
172
  - lib/libxml/document.rb
157
173
  - lib/libxml/error.rb
158
- - lib/libxml/hpricot.rb
159
174
  - lib/libxml/html_parser.rb
160
175
  - lib/libxml/namespace.rb
161
176
  - lib/libxml/namespaces.rb
@@ -168,15 +183,7 @@ files:
168
183
  - lib/libxml/schema/element.rb
169
184
  - lib/libxml/schema/type.rb
170
185
  - lib/libxml/tree.rb
171
- - lib/xml.rb
172
- - lib/xml/libxml.rb
173
186
  - libxml-ruby.gemspec
174
- - script/benchmark/depixelate
175
- - script/benchmark/hamlet.xml
176
- - script/benchmark/parsecount
177
- - script/benchmark/sock_entries.xml
178
- - script/benchmark/throughput
179
- - script/test
180
187
  - test/c14n/given/doc.dtd
181
188
  - test/c14n/given/example-1.xml
182
189
  - test/c14n/given/example-2.xml
@@ -232,7 +239,6 @@ files:
232
239
  - test/test_attr_decl.rb
233
240
  - test/test_attributes.rb
234
241
  - test/test_canonicalize.rb
235
- - test/test_deprecated_require.rb
236
242
  - test/test_document.rb
237
243
  - test/test_document_write.rb
238
244
  - test/test_dtd.rb
@@ -242,6 +248,7 @@ files:
242
248
  - test/test_helper.rb
243
249
  - test/test_html_parser.rb
244
250
  - test/test_html_parser_context.rb
251
+ - test/test_input_callbacks.rb
245
252
  - test/test_namespace.rb
246
253
  - test/test_namespaces.rb
247
254
  - test/test_node.rb
@@ -279,7 +286,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
279
286
  requirements:
280
287
  - - ">="
281
288
  - !ruby/object:Gem::Version
282
- version: '2.5'
289
+ version: '3.2'
283
290
  required_rubygems_version: !ruby/object:Gem::Requirement
284
291
  requirements:
285
292
  - - ">="
@@ -294,7 +301,6 @@ test_files:
294
301
  - test/test_attr_decl.rb
295
302
  - test/test_attributes.rb
296
303
  - test/test_canonicalize.rb
297
- - test/test_deprecated_require.rb
298
304
  - test/test_document.rb
299
305
  - test/test_document_write.rb
300
306
  - test/test_dtd.rb
@@ -304,6 +310,7 @@ test_files:
304
310
  - test/test_helper.rb
305
311
  - test/test_html_parser.rb
306
312
  - test/test_html_parser_context.rb
313
+ - test/test_input_callbacks.rb
307
314
  - test/test_namespace.rb
308
315
  - test/test_namespaces.rb
309
316
  - test/test_node.rb
data/README.rdoc DELETED
@@ -1,208 +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 3.0.0 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-mingw-ucr gem or build it yourself using (Ruby
24
- for Windows)[https://rubyinstaller.org/] or directly with msys2[https://msys2.github.io/]
25
- and ucrt64.
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 3.2 and 3.3.
50
-
51
- The gem also includes a Microsoft VC++ solution and XCode project - these
52
- are very useful for debugging.
53
-
54
- libxml-ruby's source codes lives on GitHub[https://github.com/xml4r/libxml-ruby].
55
-
56
- == Getting Started
57
- Using libxml is easy. First decide what parser you want to use:
58
-
59
- * Generally you'll want to use the LibXML::XML::Parser which provides a tree based API.
60
- * For larger documents that don't fit into memory, or if you prefer an input based API, use the LibXML::XML::Reader.
61
- * To parse HTML files use LibXML::XML::HTMLParser.
62
- * If you are masochistic, then use the LibXML::XML::SaxParser, which provides a callback API.
63
-
64
- Once you have chosen a parser, choose a datasource. Libxml can parse files, strings, URIs
65
- and IO streams. For each data source you can specify an LibXML::XML::Encoding, a base uri and
66
- various parser options. For more information, refer the LibXML::XML::Parser.document,
67
- LibXML::XML::Parser.file, LibXML::XML::Parser.io or LibXML:::XML::Parser.string methods (the
68
- same methods are defined on all four parser classes).
69
-
70
- == Advanced Functionality
71
- Beyond the basics of parsing and processing XML and HTML documents,
72
- libxml provides a wealth of additional functionality.
73
-
74
- Most commonly, you'll want to use its LibXML::XML::XPath support, which makes
75
- it easy to find data inside an XML document. Although not as popular,
76
- LibXML::XML::XPointer provides another API for finding data inside an XML document.
77
-
78
- Often times you'll need to validate data before processing it. For example,
79
- if you accept user generated content submitted over the Web, you'll
80
- want to verify that it does not contain malicious code such as embedded scripts.
81
- This can be done using libxml's powerful set of validators:
82
-
83
- * DTDs (LibXML::XML::Dtd)
84
- * Relax Schemas (LibXML::XML::RelaxNG)
85
- * XML Schema (LibXML::XML::Schema)
86
-
87
- Finally, if you'd like to use XSL Transformations to process data, then install
88
- the {libxslt gem}[https://github.com/xml4r/libxslt-rubygem].
89
-
90
- == Usage
91
- For information about using libxml-ruby please refer to its
92
- documentation[https://xml4r.github.io/libxml-ruby]. Some tutorials are also
93
- available[https://github.com/xml4r/libxml-ruby/wiki].
94
-
95
- All libxml classes are in the LibXML::XML module. The easiest
96
- way to use libxml is to <tt>require 'xml'</tt>. This will mixin
97
- the LibXML module into the global namespace, allowing you to
98
- write code like this:
99
-
100
- require 'xml'
101
- document = XML::Document.new
102
-
103
- However, when creating an application or library you plan to
104
- redistribute, it is best to not add the LibXML module to the global
105
- namespace, in which case you can either write your code like this:
106
-
107
- require 'libxml'
108
- document = LibXML::XML::Document.new
109
-
110
- Or you can utilize a namespace for your own work and include LibXML into it.
111
- For example:
112
-
113
- require 'libxml'
114
-
115
- module MyApplication
116
- include LibXML
117
-
118
- class MyClass
119
- def some_method
120
- document = XML::Document.new
121
- end
122
- end
123
- end
124
-
125
- For simplicity's sake, the documentation uses the xml module in its examples.
126
-
127
- == Tests
128
-
129
- To run tests you first need to build the shared libary:
130
-
131
- rake compile
132
-
133
- Once you have build the shared libary, you can then run tests using rake:
134
-
135
- rake test
136
-
137
- +Build status: {rdoc-image:https://github.com/xml4r/libxml-ruby/actions/workflows/mri.yml/badge.svg}[https://github.com/xml4r/libxml-ruby/actions/workflows/mri.yml]
138
-
139
- == Performance
140
-
141
- In addition to being feature rich and conformation, the main reason
142
- people use libxml-ruby is for performance. Here are the results
143
- of a couple simple benchmarks recently blogged about on the
144
- Web (you can find them in the benchmark directory of the
145
- libxml distribution).
146
-
147
- From http://depixelate.com/2008/4/23/ruby-xml-parsing-benchmarks
148
-
149
- user system total real
150
- libxml 0.032000 0.000000 0.032000 ( 0.031000)
151
- Hpricot 0.640000 0.031000 0.671000 ( 0.890000)
152
- REXML 1.813000 0.047000 1.860000 ( 2.031000)
153
-
154
- From https://svn.concord.org/svn/projects/trunk/common/ruby/xml_benchmarks/
155
-
156
- user system total real
157
- libxml 0.641000 0.031000 0.672000 ( 0.672000)
158
- hpricot 5.359000 0.062000 5.421000 ( 5.516000)
159
- rexml 22.859000 0.047000 22.906000 ( 23.203000)
160
-
161
-
162
- == Documentation
163
- Documentation is available via rdoc, and is installed automatically with the
164
- gem.
165
-
166
- libxml-ruby's {online
167
- documentation}[https://xml4r.github.io/libxml-ruby/rdoc/index.html] is generated
168
- using Hanna, which is a development gem dependency.
169
-
170
- Note that older versions of Rdoc, which ship with Ruby 1.8.x, will report
171
- a number of errors. To avoid them, install Rdoc 2.1 or higher. Once you have
172
- installed the gem, you'll have to disable the version of Rdoc that Ruby 1.8.x
173
- includes. An easy way to do that is rename the directory
174
- <tt>ruby/lib/ruby/1.8/rdoc</tt> to
175
- <tt>ruby/lib/ruby/1.8/rdoc_old</tt>.
176
-
177
- == Support
178
- If you have any questions about using libxml-ruby, please report an issue
179
- on GitHub[https://github.com/xml4r/libxml-ruby/issues].
180
-
181
- == Memory Management
182
- libxml-ruby automatically manages memory associated with the
183
- underlying libxml2 library. The bindings create a one-to-one mapping between
184
- Ruby objects and libxml documents and libxml parent nodes (ie, nodes that do not
185
- have a parent and do not belong to a document). In these cases,
186
- the bindings manage the memory. They do this by installing a free
187
- function and storing a back pointer to the Ruby object from the xmlnode
188
- using the _private member on libxml structures. When the Ruby object
189
- goes out of scope, the underlying libxml structure is freed. Libxml
190
- itself then frees all child nodes (recursively).
191
-
192
- For all other nodes (the vast majority), the bindings create temporary
193
- Ruby objects that get freed once they go out of scope. Thus there can be
194
- more than one Ruby object pointing to the same xml node. To mostly hide
195
- this from a programmer on the Ruby side, the <tt>#eql?</tt> and <tt>#==</tt> methods are
196
- overriden to check if two Ruby objects wrap the same xmlnode. If they do,
197
- then the methods return true. During the mark phase, each of these temporary
198
- objects marks its owning document, thereby keeping the Ruby document object
199
- alive and thus the xmldoc tree.
200
-
201
- In the sweep phase of the garbage collector, or when a program ends,
202
- there is no order to how Ruby objects are freed. In fact, the Ruby document
203
- object is almost always freed before any Ruby objects that wrap child nodes.
204
- However, this is ok because those Ruby objects do not have a free function
205
- and are no longer in scope (since if they were the document would not be freed).
206
-
207
- == License
208
- See LICENSE for license information.
data/ext/libxml/extconf.h DELETED
@@ -1,4 +0,0 @@
1
- #ifndef EXTCONF_H
2
- #define EXTCONF_H
3
- #define HAVE_ZLIB_H 1
4
- #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