libxml-ruby 0.8.3-x86-mswin32-60 → 0.9.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +18 -0
- data/RAKEFILE +15 -39
- data/README +48 -47
- data/ext/libxml/libxml.c +847 -22
- data/ext/libxml/ruby_libxml.h +71 -95
- data/ext/libxml/ruby_xml_attr.c +500 -500
- data/ext/libxml/ruby_xml_attributes.c +1 -1
- data/ext/libxml/ruby_xml_document.c +1144 -1135
- data/ext/libxml/ruby_xml_document.h +4 -11
- data/ext/libxml/ruby_xml_dtd.c +27 -0
- data/ext/libxml/ruby_xml_encoding.c +164 -0
- data/ext/libxml/ruby_xml_encoding.h +13 -0
- data/ext/libxml/ruby_xml_error.c +941 -0
- data/ext/libxml/ruby_xml_error.h +13 -0
- data/ext/libxml/ruby_xml_html_parser.c +71 -387
- data/ext/libxml/ruby_xml_html_parser.h +1 -17
- data/ext/libxml/ruby_xml_input.c +179 -0
- data/ext/libxml/ruby_xml_input.h +18 -0
- data/ext/libxml/ruby_xml_input_cbg.c +17 -3
- data/ext/libxml/ruby_xml_node.c +1566 -1582
- data/ext/libxml/ruby_xml_node.h +1 -4
- data/ext/libxml/ruby_xml_ns.c +14 -3
- data/ext/libxml/ruby_xml_parser.c +164 -1398
- data/ext/libxml/ruby_xml_parser.h +5 -17
- data/ext/libxml/ruby_xml_parser_context.c +131 -169
- data/ext/libxml/ruby_xml_parser_context.h +2 -9
- data/ext/libxml/ruby_xml_reader.c +910 -945
- data/ext/libxml/ruby_xml_relaxng.c +32 -3
- data/ext/libxml/ruby_xml_sax_parser.c +106 -364
- data/ext/libxml/ruby_xml_sax_parser.h +1 -37
- data/ext/libxml/ruby_xml_schema.c +174 -145
- data/ext/libxml/ruby_xml_xinclude.c +9 -5
- data/ext/libxml/ruby_xml_xpath.c +25 -6
- data/ext/libxml/ruby_xml_xpath.h +1 -2
- data/ext/libxml/ruby_xml_xpath_context.c +17 -19
- data/ext/libxml/ruby_xml_xpath_object.c +60 -56
- data/ext/libxml/ruby_xml_xpointer.c +11 -5
- data/ext/libxml/sax_parser_callbacks.inc +42 -37
- data/ext/libxml/version.h +3 -3
- data/ext/mingw/Rakefile +20 -27
- data/ext/mingw/build.rake +41 -0
- data/{lib → ext/mingw}/libiconv-2.dll +0 -0
- data/ext/mingw/libxml2-2.dll +0 -0
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +23 -15
- data/lib/libxml.rb +8 -2
- data/lib/libxml/document.rb +16 -4
- data/lib/libxml/error.rb +84 -0
- data/lib/libxml/hpricot.rb +76 -0
- data/lib/libxml/html_parser.rb +61 -0
- data/lib/libxml/node.rb +36 -25
- data/lib/libxml/parser.rb +312 -33
- data/lib/libxml/parser_context.rb +17 -0
- data/lib/libxml/properties.rb +15 -2
- data/lib/libxml/reader.rb +15 -0
- data/lib/libxml/sax_callbacks.rb +179 -0
- data/lib/libxml/sax_parser.rb +42 -0
- data/lib/libxml/tree.rb +1 -2
- data/lib/libxml/xpath_object.rb +12 -0
- data/test/model/atom.xml +4 -0
- data/test/tc_attributes.rb +43 -19
- data/test/tc_document.rb +1 -1
- data/test/tc_document_write.rb +15 -8
- data/test/tc_dtd.rb +36 -20
- data/test/tc_encoding.rb +13 -0
- data/test/tc_error.rb +136 -0
- data/test/tc_node.rb +2 -3
- data/test/tc_node_copy.rb +1 -1
- data/test/tc_node_edit.rb +6 -0
- data/test/tc_ns.rb +18 -0
- data/test/tc_parser.rb +113 -228
- data/test/tc_parser_context.rb +1 -2
- data/test/tc_reader.rb +24 -14
- data/test/tc_relaxng.rb +18 -6
- data/test/tc_sax_parser.rb +48 -13
- data/test/tc_schema.rb +20 -8
- data/test/tc_well_formed.rb +2 -1
- data/test/tc_xml.rb +212 -0
- data/test/tc_xpath.rb +60 -46
- data/test/tc_xpointer.rb +7 -11
- data/test/test_suite.rb +4 -3
- metadata +32 -115
- data/doc/rdoc/classes/LibXML.html +0 -241
- data/doc/rdoc/classes/LibXML/XML.html +0 -185
- data/doc/rdoc/classes/LibXML/XML/Attr.html +0 -1010
- data/doc/rdoc/classes/LibXML/XML/Attributes.html +0 -526
- data/doc/rdoc/classes/LibXML/XML/Document.html +0 -1489
- data/doc/rdoc/classes/LibXML/XML/Dtd.html +0 -213
- data/doc/rdoc/classes/LibXML/XML/Error.html +0 -117
- data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +0 -348
- data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +0 -160
- data/doc/rdoc/classes/LibXML/XML/NS.html +0 -381
- data/doc/rdoc/classes/LibXML/XML/Node.html +0 -3396
- data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Node/Set.html +0 -440
- data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Parser.html +0 -2239
- data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +0 -1255
- data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/Reader.html +0 -2264
- data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +0 -237
- data/doc/rdoc/classes/LibXML/XML/SaxParser.html +0 -415
- data/doc/rdoc/classes/LibXML/XML/Schema.html +0 -308
- data/doc/rdoc/classes/LibXML/XML/State.html +0 -124
- data/doc/rdoc/classes/LibXML/XML/Tree.html +0 -111
- data/doc/rdoc/classes/LibXML/XML/XInclude.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +0 -117
- data/doc/rdoc/classes/LibXML/XML/XMLParserOptions.html +0 -198
- data/doc/rdoc/classes/LibXML/XML/XPath.html +0 -184
- data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +0 -404
- data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +0 -172
- data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +0 -627
- data/doc/rdoc/classes/LibXML/XML/XPointer.html +0 -170
- data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +0 -123
- data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +0 -117
- data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +0 -124
- data/doc/rdoc/classes/singleton.html +0 -114
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/CHANGES.html +0 -442
- data/doc/rdoc/files/LICENSE.html +0 -133
- data/doc/rdoc/files/README.html +0 -388
- data/doc/rdoc/files/VERSION.html +0 -107
- data/doc/rdoc/files/ext/libxml/cbg_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/libxml_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +0 -101
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +0 -101
- data/doc/rdoc/files/lib/libxml/attr_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/attributes_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/document_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/node_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/node_set_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/parser_options_rb.html +0 -107
- data/doc/rdoc/files/lib/libxml/parser_rb.html +0 -101
- data/doc/rdoc/files/lib/libxml/properties_rb.html +0 -108
- data/doc/rdoc/files/lib/libxml/tree_rb.html +0 -107
- data/doc/rdoc/files/lib/libxml_rb.html +0 -124
- data/doc/rdoc/files/lib/xml/libxml_rb.html +0 -124
- data/doc/rdoc/files/lib/xml_rb.html +0 -134
- data/doc/rdoc/fr_class_index.html +0 -62
- data/doc/rdoc/fr_file_index.html +0 -66
- data/doc/rdoc/fr_method_index.html +0 -392
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/ext/libxml/ruby_xml_node_set.c +0 -172
- data/ext/libxml/ruby_xml_node_set.h +0 -20
- data/ext/libxml/ruby_xml_xpointer_context.c +0 -22
- data/ext/libxml/ruby_xml_xpointer_context.h +0 -18
- data/lib/libxml/node_set.rb +0 -27
- data/lib/libxml2-2.dll +0 -0
- data/lib/libxml_ruby.dll.a +0 -0
- data/lib/libxml_ruby.so +0 -0
- data/test/tc_node_set.rb +0 -24
- data/test/tc_node_set2.rb +0 -37
data/CHANGES
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
(See log/ChangeLog for more detailed changes derived directly from source control.)
|
2
2
|
|
3
|
+
== 0.9.0 / 2008-11-18 Charlie Savage
|
4
|
+
|
5
|
+
* Expose LibXML's encoding support via a new Encoding object.
|
6
|
+
|
7
|
+
* Revamp error handling to be much easier to use. Errors are now
|
8
|
+
wrapped by the new XML::Error class and are thrown as exceptions
|
9
|
+
when it is appropriate.
|
10
|
+
|
11
|
+
* Fixed segementation fault caused by documents being freed
|
12
|
+
before xpath results that referenced the document.
|
13
|
+
|
14
|
+
* Add Node#register_default_namespace to simplify default namespace handling.
|
15
|
+
|
16
|
+
* Significantly improve documentation
|
17
|
+
|
18
|
+
* A number of bug fixes and patches.
|
19
|
+
|
20
|
+
|
3
21
|
== 0.8.3 / 2008-07-21 Charlie Savage
|
4
22
|
|
5
23
|
* Missed several files in last release
|
data/RAKEFILE
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# Be sure to set ENV['RUBYFORGE_USERNAME'] to use publish.
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
|
-
require 'date'
|
7
6
|
require 'rake/gempackagetask'
|
8
7
|
require 'rake/rdoctask'
|
9
8
|
require 'rake/testtask'
|
@@ -20,6 +19,7 @@ FILES = FileList[
|
|
20
19
|
'doc/**/*',
|
21
20
|
'ext/libxml/*',
|
22
21
|
'ext/mingw/Rakefile',
|
22
|
+
'ext/mingw/build.rake',
|
23
23
|
'ext/vc/*.sln',
|
24
24
|
'ext/vc/*.vcproj',
|
25
25
|
'lib/**/*',
|
@@ -69,47 +69,26 @@ end
|
|
69
69
|
Rake::GemPackageTask.new(default_spec) do |pkg|
|
70
70
|
pkg.package_dir = 'admin/pkg'
|
71
71
|
pkg.need_tar = true
|
72
|
-
pkg.need_zip = true
|
73
72
|
end
|
74
73
|
|
75
74
|
|
76
|
-
# ------- Windows
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
'ext/mingw/*.dll*'])
|
81
|
-
|
82
|
-
# Windows specification
|
83
|
-
win_spec = default_spec.clone
|
84
|
-
win_spec.extensions = []
|
85
|
-
win_spec.platform = Gem::Platform::CURRENT
|
86
|
-
win_spec.files += binaries.map {|binaryname| "lib/#{File.basename(binaryname)}"}
|
75
|
+
# ------- Windows GEM ----------
|
76
|
+
if RUBY_PLATFORM.match(/win32/)
|
77
|
+
binaries = (FileList['ext/mingw/*.so',
|
78
|
+
'ext/mingw/*.dll*'])
|
87
79
|
|
80
|
+
# Windows specification
|
81
|
+
win_spec = default_spec.clone
|
82
|
+
win_spec.extensions = ['ext/mingw/Rakefile']
|
83
|
+
win_spec.platform = Gem::Platform::CURRENT
|
84
|
+
win_spec.files += binaries.to_a
|
88
85
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
# since there are no dependencies of msvcr80.dll
|
93
|
-
current_dir = File.expand_path(File.dirname(__FILE__))
|
94
|
-
|
95
|
-
binaries.each do |binaryname|
|
96
|
-
target = File.join(current_dir, 'lib', File.basename(binaryname))
|
97
|
-
cp(binaryname, target)
|
98
|
-
end
|
99
|
-
|
100
|
-
# Create the gem, then move it to admin/pkg
|
101
|
-
Gem::Builder.new(win_spec).build
|
102
|
-
gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
|
103
|
-
mv(gem_file, "admin/pkg/#{gem_file}")
|
104
|
-
|
105
|
-
# Remove win extension from top level directory
|
106
|
-
binaries.each do |binaryname|
|
107
|
-
target = File.join(current_dir, 'lib', File.basename(binaryname))
|
108
|
-
rm(target)
|
86
|
+
# Rake task to build the windows package
|
87
|
+
Rake::GemPackageTask.new(win_spec) do |pkg|
|
88
|
+
pkg.package_dir = 'admin/pkg'
|
109
89
|
end
|
110
90
|
end
|
111
91
|
|
112
|
-
|
113
92
|
# --------- RDoc Documentation ---------
|
114
93
|
desc "Generate rdoc documentation"
|
115
94
|
Rake::RDocTask.new("rdoc") do |rdoc|
|
@@ -128,9 +107,6 @@ Rake::RDocTask.new("rdoc") do |rdoc|
|
|
128
107
|
'VERSION')
|
129
108
|
end
|
130
109
|
|
131
|
-
task :default => :package
|
132
|
-
task :package => :create_win32_gem
|
133
|
-
|
134
110
|
Rake::TestTask.new do |t|
|
135
111
|
t.libs << "test"
|
136
112
|
t.libs << "lib"
|
@@ -141,6 +117,7 @@ if not RUBY_PLATFORM.match(/mswin32/i)
|
|
141
117
|
Rake::Task[:test].prerequisites << :extensions
|
142
118
|
end
|
143
119
|
|
120
|
+
task :default => :package
|
144
121
|
task :build => :extensions
|
145
122
|
task :extension => :build
|
146
123
|
|
@@ -161,9 +138,8 @@ namespace :extensions do
|
|
161
138
|
end
|
162
139
|
|
163
140
|
file "ext/libxml/Makefile" => ["ext/libxml/extconf.rb"] do
|
164
|
-
|
165
141
|
command = ["ruby"] + $:.map{|dir| "-I#{File.expand_path dir}"} + ["extconf.rb"]
|
166
|
-
Dir.chdir("ext/libxml") { sh
|
142
|
+
Dir.chdir("ext/libxml") { sh(*command) }
|
167
143
|
end
|
168
144
|
|
169
145
|
# --------- Publish Website to Rubyforge ---------
|
data/README
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
= LibXML Ruby
|
2
2
|
|
3
3
|
== Overview
|
4
|
-
|
5
4
|
The libxml gem provides Ruby language bindings for GNOME's Libxml2
|
6
5
|
XML toolkit. It is free software, released under the MIT License.
|
7
6
|
|
@@ -13,7 +12,6 @@ libxml-ruby provides several advantages over REXML:
|
|
13
12
|
|
14
13
|
|
15
14
|
== Requirements
|
16
|
-
|
17
15
|
libxml-ruby requires Ruby 1.8.4 or higher. It is dependent on
|
18
16
|
the following libraries to function properly:
|
19
17
|
|
@@ -22,44 +20,41 @@ the following libraries to function properly:
|
|
22
20
|
* libiconv
|
23
21
|
* libxml2
|
24
22
|
|
25
|
-
If you are running Linux or Unix you'll need a C compiler so the
|
26
|
-
can be compiled when it is installed. If you are running
|
23
|
+
If you are running Linux or Unix you'll need a C compiler so the
|
24
|
+
extension can be compiled when it is installed. If you are running
|
25
|
+
Windows, then install the Windows specific RubyGem which
|
27
26
|
includes an already built extension.
|
28
27
|
|
29
|
-
|
30
28
|
== INSTALLATION
|
31
|
-
|
32
29
|
The easiest way to install libxml-ruby is via Ruby Gems. To install:
|
33
30
|
|
34
31
|
<tt>gem install libxml-ruby</tt>
|
35
32
|
|
36
|
-
If you are running Windows, make sure to install the Win32 RubyGem
|
37
|
-
includes an already built binary file. The binary is built
|
38
|
-
libxml2 version 2.6.32 and iconv version 1.11. Both of these
|
39
|
-
included as pre-built binaries, and should be put either in
|
40
|
-
libxml/lib directory or on the Windows path.
|
33
|
+
If you are running Windows, make sure to install the Win32 RubyGem
|
34
|
+
which includes an already built binary file. The binary is built
|
35
|
+
against libxml2 version 2.6.32 and iconv version 1.11. Both of these
|
36
|
+
are also included as pre-built binaries, and should be put either in
|
37
|
+
the libxml/lib directory or on the Windows path.
|
41
38
|
|
42
39
|
The Windows binaries are built with MingW and include libxml-ruby,
|
43
40
|
libxml2 and iconv. The gem also includes a Microsoft VC++ 2008
|
44
41
|
solution. If you wish to run a debug version of libxml-ruby on
|
45
42
|
Windows, then it is highly recommended you use VC++.
|
46
43
|
|
47
|
-
|
48
44
|
== Functionality
|
49
|
-
|
50
|
-
from the OASIS XML Tests Suite.
|
51
|
-
|
52
|
-
|
53
|
-
* SAX
|
54
|
-
*
|
55
|
-
*
|
56
|
-
*
|
57
|
-
*
|
58
|
-
*
|
59
|
-
*
|
60
|
-
*
|
61
|
-
*
|
62
|
-
* XSLT (split into the libxslt-ruby bindings)
|
45
|
+
LibXML is a highly conformant XML parser, passing all 1800+ tests
|
46
|
+
from the OASIS XML Tests Suite. It includes rich functionality such as:
|
47
|
+
|
48
|
+
* DOM (LibXML::XML::Parser)
|
49
|
+
* SAX (LibXML::XML::SaxParser)
|
50
|
+
* HTML Parsing (LibXML::XML::HTMLParser)
|
51
|
+
* Reader (LibXML::XML::Reader)
|
52
|
+
* XPath (LibXML::XML::XPath)
|
53
|
+
* XPointer (LibXML::XML::XPointer)
|
54
|
+
* DTDs (LibXML::XML::Dtd)
|
55
|
+
* RelaxNG Schemas (LibXML::XML::RelaxNG)
|
56
|
+
* XML Schema (LibXML::XML::Schema)
|
57
|
+
* XSLT (http://rubyforge.org/projects/libxsl/)
|
63
58
|
|
64
59
|
libxml-ruby provides impressive coverage of libxml's functionality
|
65
60
|
through an easy-to-use C api.
|
@@ -89,29 +84,40 @@ From https://svn.concord.org/svn/projects/trunk/common/ruby/xml_benchmarks/
|
|
89
84
|
For in-depth information about using libxml-ruby please refer
|
90
85
|
to its online Rdoc documentation.
|
91
86
|
|
92
|
-
All libxml classes are in the LibXML::XML module. The
|
93
|
-
way to use libxml is to require 'xml'. This will mixin
|
94
|
-
LibXML module into the global namespace, allowing you to
|
87
|
+
All libxml classes are in the LibXML::XML module. The most
|
88
|
+
expedient way to use libxml is to require 'xml'. This will mixin
|
89
|
+
the LibXML module into the global namespace, allowing you to
|
95
90
|
write code like this:
|
96
91
|
|
97
|
-
require 'xml'
|
98
|
-
document = XML::Document.new
|
92
|
+
require 'xml'
|
93
|
+
document = XML::Document.new
|
94
|
+
|
95
|
+
However, when creating an application or library you plan to
|
96
|
+
redistribute, it is best to not add the LibXML module to the global
|
97
|
+
namespace, in which case you can either write your code like this:
|
98
|
+
|
99
|
+
require 'libxml'
|
100
|
+
document = LibXML::XML::Document.new
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
+
or, more conveniently, utilize a proper namespace for you own work
|
103
|
+
and include LibXML into it. For example:
|
102
104
|
|
103
|
-
require 'libxml'
|
105
|
+
require 'libxml'
|
104
106
|
|
105
|
-
|
106
|
-
|
107
|
-
|
107
|
+
mdoule MyApplication
|
108
|
+
include LibXML
|
109
|
+
|
110
|
+
class MyClass
|
111
|
+
def some_method
|
112
|
+
document = XML::Document.new
|
113
|
+
end
|
114
|
+
end
|
108
115
|
end
|
109
|
-
end
|
110
116
|
|
111
|
-
|
117
|
+
For simplicity's sake we will use require 'xml in the basic examples
|
118
|
+
shown below.
|
112
119
|
|
113
120
|
=== READING
|
114
|
-
|
115
121
|
There are several ways to read xml documents.
|
116
122
|
|
117
123
|
require 'xml'
|
@@ -127,7 +133,7 @@ There are several ways to read xml documents.
|
|
127
133
|
puts "Node path: #{node.path} \t Contents: #{node.content}"
|
128
134
|
end
|
129
135
|
|
130
|
-
And your terminal should look like:
|
136
|
+
And your terminal should look like this:
|
131
137
|
|
132
138
|
Root element name: root_node
|
133
139
|
Elem3: baz
|
@@ -142,9 +148,7 @@ And your terminal should look like:
|
|
142
148
|
Node path: /root_node/foo/bar[9] Contents: 9
|
143
149
|
Node path: /root_node/foo/bar[10] Contents: 10
|
144
150
|
|
145
|
-
|
146
151
|
=== WRITING
|
147
|
-
|
148
152
|
To write a simple document:
|
149
153
|
|
150
154
|
require 'xml'
|
@@ -200,17 +204,14 @@ The file output.xml contains:
|
|
200
204
|
</root_node>
|
201
205
|
|
202
206
|
== DOCUMENTATION
|
203
|
-
|
204
207
|
RDoc comments are included - run 'rake doc' to generate documentation.
|
205
208
|
You can find the latest documentation at:
|
206
209
|
|
207
210
|
* http://libxml.rubyforge.org/rdoc/
|
208
211
|
|
209
212
|
== License
|
210
|
-
|
211
213
|
See LICENSE for license information.
|
212
214
|
|
213
215
|
== MORE INFORMATION
|
214
|
-
|
215
216
|
For more information please refer to the documentation. If you have any
|
216
|
-
questions, please send email to libxml-devel@rubyforge.org.
|
217
|
+
questions, please send email to libxml-devel@rubyforge.org.
|
data/ext/libxml/libxml.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: libxml.c
|
1
|
+
/* $Id: libxml.c 585 2008-11-18 17:40:45Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -6,55 +6,880 @@
|
|
6
6
|
|
7
7
|
VALUE mLibXML;
|
8
8
|
VALUE mXML;
|
9
|
-
VALUE eXMLError;
|
10
9
|
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
/*
|
12
|
+
* call-seq:
|
13
|
+
* XML.catalog_dump -> true
|
14
|
+
*
|
15
|
+
* Dump all the global catalog content stdout.
|
16
|
+
*/
|
17
|
+
VALUE
|
18
|
+
ruby_xml_catalog_dump(VALUE self) {
|
19
|
+
xmlCatalogDump(stdout);
|
20
|
+
return(Qtrue);
|
21
|
+
}
|
22
|
+
|
23
|
+
|
24
|
+
/*
|
25
|
+
* call-seq:
|
26
|
+
* XML.catalog_remove(catalog) -> true
|
27
|
+
*
|
28
|
+
* Remove the specified resource catalog.
|
29
|
+
*/
|
30
|
+
VALUE
|
31
|
+
ruby_xml_catalog_remove(VALUE self, VALUE cat) {
|
32
|
+
Check_Type(cat, T_STRING);
|
33
|
+
xmlCatalogRemove((xmlChar *)StringValuePtr(cat));
|
34
|
+
return(Qtrue);
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
/*
|
39
|
+
* call-seq:
|
40
|
+
* XML.check_lib_versions -> true
|
41
|
+
*
|
42
|
+
* Check LIBXML version matches version the bindings
|
43
|
+
* were compiled to. Throws an exception if not.
|
44
|
+
*/
|
45
|
+
VALUE
|
46
|
+
ruby_xml_check_lib_versions(VALUE class) {
|
47
|
+
xmlCheckVersion(LIBXML_VERSION);
|
48
|
+
return(Qtrue);
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* XML.enabled_automata? -> (true|false)
|
55
|
+
*
|
56
|
+
* Determine whether libxml regexp automata support is enabled.
|
57
|
+
*/
|
58
|
+
VALUE
|
59
|
+
ruby_xml_enabled_automata_q(VALUE class) {
|
60
|
+
#ifdef LIBXML_AUTOMATA_ENABLED
|
61
|
+
return(Qtrue);
|
62
|
+
#else
|
63
|
+
return(Qfalse);
|
14
64
|
#endif
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
/*
|
69
|
+
* call-seq:
|
70
|
+
* XML.enabled_c14n? -> (true|false)
|
71
|
+
*
|
72
|
+
* Determine whether libxml 'canonical XML' support is enabled.
|
73
|
+
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
74
|
+
*/
|
75
|
+
VALUE
|
76
|
+
ruby_xml_enabled_c14n_q(VALUE class) {
|
77
|
+
#ifdef LIBXML_C14N_ENABLED
|
78
|
+
return(Qtrue);
|
79
|
+
#else
|
80
|
+
return(Qfalse);
|
81
|
+
#endif
|
82
|
+
}
|
83
|
+
|
84
|
+
|
85
|
+
/*
|
86
|
+
* call-seq:
|
87
|
+
* XML.enabled_catalog? -> (true|false)
|
88
|
+
*
|
89
|
+
* Determine whether libxml resource catalog support is enabled.
|
90
|
+
*/
|
91
|
+
VALUE
|
92
|
+
ruby_xml_enabled_catalog_q(VALUE class) {
|
93
|
+
#ifdef LIBXML_CATALOG_ENABLED
|
94
|
+
return(Qtrue);
|
95
|
+
#else
|
96
|
+
return(Qfalse);
|
97
|
+
#endif
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
/*
|
102
|
+
* call-seq:
|
103
|
+
* XML.enabled_debug? -> (true|false)
|
104
|
+
*
|
105
|
+
* Determine whether libxml debugging support is enabled.
|
106
|
+
*/
|
107
|
+
VALUE
|
108
|
+
ruby_xml_enabled_debug_q(VALUE class) {
|
109
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
110
|
+
return(Qtrue);
|
111
|
+
#else
|
112
|
+
return(Qfalse);
|
113
|
+
#endif
|
114
|
+
}
|
115
|
+
|
116
|
+
|
117
|
+
/*
|
118
|
+
* call-seq:
|
119
|
+
* XML.enabled_docbook? -> (true|false)
|
120
|
+
*
|
121
|
+
* Determine whether libxml docbook support is enabled.
|
122
|
+
*/
|
123
|
+
VALUE
|
124
|
+
ruby_xml_enabled_docbook_q(VALUE class) {
|
125
|
+
#ifdef LIBXML_DOCB_ENABLED
|
126
|
+
return(Qtrue);
|
127
|
+
#else
|
128
|
+
return(Qfalse);
|
129
|
+
#endif
|
130
|
+
}
|
131
|
+
|
132
|
+
|
133
|
+
/*
|
134
|
+
* call-seq:
|
135
|
+
* XML.enabled_ftp? -> (true|false)
|
136
|
+
*
|
137
|
+
* Determine whether libxml ftp client support is enabled.
|
138
|
+
*/
|
139
|
+
VALUE
|
140
|
+
ruby_xml_enabled_ftp_q(VALUE class) {
|
141
|
+
#ifdef LIBXML_FTP_ENABLED
|
142
|
+
return(Qtrue);
|
143
|
+
#else
|
144
|
+
return(Qfalse);
|
145
|
+
#endif
|
146
|
+
}
|
147
|
+
|
148
|
+
|
149
|
+
/*
|
150
|
+
* call-seq:
|
151
|
+
* XML.enabled_http? -> (true|false)
|
152
|
+
*
|
153
|
+
* Determine whether libxml http client support is enabled.
|
154
|
+
*/
|
155
|
+
VALUE
|
156
|
+
ruby_xml_enabled_http_q(VALUE class) {
|
157
|
+
#ifdef LIBXML_HTTP_ENABLED
|
158
|
+
return(Qtrue);
|
159
|
+
#else
|
160
|
+
return(Qfalse);
|
161
|
+
#endif
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
/*
|
166
|
+
* call-seq:
|
167
|
+
* XML.enabled_html? -> (true|false)
|
168
|
+
*
|
169
|
+
* Determine whether libxml html support is enabled.
|
170
|
+
*/
|
171
|
+
VALUE
|
172
|
+
ruby_xml_enabled_html_q(VALUE class) {
|
173
|
+
#ifdef LIBXML_HTML_ENABLED
|
174
|
+
return(Qtrue);
|
175
|
+
#else
|
176
|
+
return(Qfalse);
|
177
|
+
#endif
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
/*
|
182
|
+
* call-seq:
|
183
|
+
* XML.enabled_iconv? -> (true|false)
|
184
|
+
*
|
185
|
+
* Determine whether libxml iconv support is enabled.
|
186
|
+
*/
|
187
|
+
VALUE
|
188
|
+
ruby_xml_enabled_iconv_q(VALUE class) {
|
189
|
+
#ifdef LIBXML_ICONV_ENABLED
|
190
|
+
return(Qtrue);
|
191
|
+
#else
|
192
|
+
return(Qfalse);
|
193
|
+
#endif
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
/*
|
198
|
+
* call-seq:
|
199
|
+
* XML.enabled_memory_debug? -> (true|false)
|
200
|
+
*
|
201
|
+
* Determine whether libxml memory location debugging support
|
202
|
+
* is enabled.
|
203
|
+
*/
|
204
|
+
VALUE
|
205
|
+
ruby_xml_enabled_memory_debug_location_q(VALUE class) {
|
206
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
207
|
+
return(Qtrue);
|
208
|
+
#else
|
209
|
+
return(Qfalse);
|
210
|
+
#endif
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
/*
|
215
|
+
* call-seq:
|
216
|
+
* XML.enabled_regexp? -> (true|false)
|
217
|
+
*
|
218
|
+
* Determine whether libxml regular expression support is enabled.
|
219
|
+
*/
|
220
|
+
VALUE
|
221
|
+
ruby_xml_enabled_regexp_q(VALUE class) {
|
222
|
+
#ifdef LIBXML_REGEXP_ENABLED
|
223
|
+
return(Qtrue);
|
224
|
+
#else
|
225
|
+
return(Qfalse);
|
226
|
+
#endif
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
/*
|
231
|
+
* call-seq:
|
232
|
+
* XML.enabled_schemas? -> (true|false)
|
233
|
+
*
|
234
|
+
* Determine whether libxml schema support is enabled.
|
235
|
+
*/
|
236
|
+
VALUE
|
237
|
+
ruby_xml_enabled_schemas_q(VALUE class) {
|
238
|
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
239
|
+
return(Qtrue);
|
240
|
+
#else
|
241
|
+
return(Qfalse);
|
242
|
+
#endif
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
/*
|
247
|
+
* call-seq:
|
248
|
+
* XML.enabled_thread? -> (true|false)
|
249
|
+
*
|
250
|
+
* Determine whether libxml thread-safe semantics support
|
251
|
+
* is enabled (I think?).
|
252
|
+
*/
|
253
|
+
VALUE
|
254
|
+
ruby_xml_enabled_thread_q(VALUE class) {
|
255
|
+
#ifdef LIBXML_THREAD_ENABLED
|
256
|
+
return(Qtrue);
|
257
|
+
#else
|
258
|
+
return(Qfalse);
|
259
|
+
#endif
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
/*
|
264
|
+
* call-seq:
|
265
|
+
* XML.enabled_unicode? -> (true|false)
|
266
|
+
*
|
267
|
+
* Determine whether libxml unicode support is enabled.
|
268
|
+
*/
|
269
|
+
VALUE
|
270
|
+
ruby_xml_enabled_unicode_q(VALUE class) {
|
271
|
+
#ifdef LIBXML_UNICODE_ENABLED
|
272
|
+
return(Qtrue);
|
273
|
+
#else
|
274
|
+
return(Qfalse);
|
275
|
+
#endif
|
276
|
+
}
|
277
|
+
|
278
|
+
|
279
|
+
/*
|
280
|
+
* call-seq:
|
281
|
+
* XML.enabled_xinclude? -> (true|false)
|
282
|
+
*
|
283
|
+
* Determine whether libxml xinclude support is enabled.
|
284
|
+
*/
|
285
|
+
VALUE
|
286
|
+
ruby_xml_enabled_xinclude_q(VALUE class) {
|
287
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
288
|
+
return(Qtrue);
|
289
|
+
#else
|
290
|
+
return(Qfalse);
|
291
|
+
#endif
|
292
|
+
}
|
293
|
+
|
294
|
+
|
295
|
+
/*
|
296
|
+
* call-seq:
|
297
|
+
* XML.enabled_xpath? -> (true|false)
|
298
|
+
*
|
299
|
+
* Determine whether libxml xpath support is enabled.
|
300
|
+
*/
|
301
|
+
VALUE
|
302
|
+
ruby_xml_enabled_xpath_q(VALUE class) {
|
303
|
+
#ifdef LIBXML_XPATH_ENABLED
|
304
|
+
return(Qtrue);
|
305
|
+
#else
|
306
|
+
return(Qfalse);
|
307
|
+
#endif
|
308
|
+
}
|
309
|
+
|
310
|
+
|
311
|
+
/*
|
312
|
+
* call-seq:
|
313
|
+
* XML.enabled_xpointer? -> (true|false)
|
314
|
+
*
|
315
|
+
* Determine whether libxml xpointer support is enabled.
|
316
|
+
*/
|
317
|
+
VALUE
|
318
|
+
ruby_xml_enabled_xpointer_q(VALUE class) {
|
319
|
+
#ifdef LIBXML_XPTR_ENABLED
|
320
|
+
return(Qtrue);
|
321
|
+
#else
|
322
|
+
return(Qfalse);
|
323
|
+
#endif
|
324
|
+
}
|
325
|
+
|
326
|
+
|
327
|
+
/*
|
328
|
+
* call-seq:
|
329
|
+
* XML.enabled_zlib? -> (true|false)
|
330
|
+
*
|
331
|
+
* Determine whether libxml zlib support is enabled.
|
332
|
+
*/
|
333
|
+
VALUE
|
334
|
+
ruby_xml_enabled_zlib_q(VALUE class) {
|
335
|
+
#ifdef HAVE_ZLIB_H
|
336
|
+
return(Qtrue);
|
337
|
+
#else
|
338
|
+
return(Qfalse);
|
339
|
+
#endif
|
340
|
+
}
|
341
|
+
|
342
|
+
|
343
|
+
/*
|
344
|
+
* call-seq:
|
345
|
+
* XML.debug_entities -> (true|false)
|
346
|
+
*
|
347
|
+
* Determine whether included-entity debugging is enabled.
|
348
|
+
* (Requires Libxml to be compiled with debugging support)
|
349
|
+
*/
|
350
|
+
VALUE
|
351
|
+
ruby_xml_debug_entities_get(VALUE class) {
|
352
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
353
|
+
if (xmlParserDebugEntities)
|
354
|
+
return(Qtrue);
|
355
|
+
else
|
356
|
+
return(Qfalse);
|
357
|
+
#else
|
358
|
+
rb_warn("libxml was compiled with debugging turned off");
|
359
|
+
return(Qfalse);
|
360
|
+
#endif
|
361
|
+
}
|
15
362
|
|
16
|
-
void
|
17
|
-
Init_libxml_ruby(void) {
|
18
|
-
/* Some libxml memory goo that should be done before anything else */
|
19
|
-
#ifdef NONE
|
20
|
-
xmlMemGet((xmlFreeFunc *) & freeFunc,
|
21
|
-
(xmlMallocFunc *) & mallocFunc,
|
22
|
-
(xmlReallocFunc *) & reallocFunc,
|
23
|
-
(xmlStrdupFunc *) & strdupFunc);
|
24
363
|
|
25
|
-
|
26
|
-
|
27
|
-
|
364
|
+
/*
|
365
|
+
* call-seq:
|
366
|
+
* XML.debug_entities = true|false
|
367
|
+
*
|
368
|
+
* Enable or disable included-entity debugging.
|
369
|
+
* (Requires Libxml to be compiled with debugging support)
|
370
|
+
*/
|
371
|
+
VALUE
|
372
|
+
ruby_xml_debug_entities_set(VALUE class, VALUE bool) {
|
373
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
374
|
+
if (TYPE(bool) == T_FALSE) {
|
375
|
+
xmlParserDebugEntities = 0;
|
376
|
+
return(Qfalse);
|
377
|
+
} else {
|
378
|
+
xmlParserDebugEntities = 1;
|
379
|
+
return(Qtrue);
|
380
|
+
}
|
381
|
+
#else
|
382
|
+
rb_warn("libxml was compiled with debugging turned off");
|
28
383
|
#endif
|
384
|
+
}
|
385
|
+
|
386
|
+
|
387
|
+
/*
|
388
|
+
* call-seq:
|
389
|
+
* XML.default_keep_blanks -> (true|false)
|
390
|
+
*
|
391
|
+
* Determine whether parsers retain whitespace by default.
|
392
|
+
*/
|
393
|
+
VALUE
|
394
|
+
ruby_xml_default_keep_blanks_get(VALUE class) {
|
395
|
+
if (xmlKeepBlanksDefaultValue)
|
396
|
+
return(Qtrue);
|
397
|
+
else
|
398
|
+
return(Qfalse);
|
399
|
+
}
|
400
|
+
|
401
|
+
|
402
|
+
/*
|
403
|
+
* call-seq:
|
404
|
+
* XML.default_keep_blanks = true|false
|
405
|
+
*
|
406
|
+
* Controls whether parsers retain whitespace by default.
|
407
|
+
*/
|
408
|
+
VALUE
|
409
|
+
ruby_xml_default_keep_blanks_set(VALUE class, VALUE bool) {
|
410
|
+
if (TYPE(bool) == T_FALSE) {
|
411
|
+
xmlKeepBlanksDefaultValue = 0;
|
412
|
+
return(Qfalse);
|
413
|
+
} else if (TYPE(bool) == T_TRUE) {
|
414
|
+
xmlKeepBlanksDefaultValue = 1;
|
415
|
+
return(Qtrue);
|
416
|
+
} else {
|
417
|
+
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
|
418
|
+
}
|
419
|
+
}
|
420
|
+
|
421
|
+
|
422
|
+
/*
|
423
|
+
* call-seq:
|
424
|
+
* XML.default_load_external_dtd -> (true|false)
|
425
|
+
*
|
426
|
+
* Determine whether parsers load external DTDs by default.
|
427
|
+
*/
|
428
|
+
VALUE
|
429
|
+
ruby_xml_default_load_external_dtd_get(VALUE class) {
|
430
|
+
if (xmlLoadExtDtdDefaultValue)
|
431
|
+
return(Qtrue);
|
432
|
+
else
|
433
|
+
return(Qfalse);
|
434
|
+
}
|
435
|
+
|
436
|
+
|
437
|
+
/*
|
438
|
+
* call-seq:
|
439
|
+
* XML.default_load_external_dtd = true|false
|
440
|
+
*
|
441
|
+
* Controls whether parsers load external DTDs by default.
|
442
|
+
*/
|
443
|
+
VALUE
|
444
|
+
ruby_xml_default_load_external_dtd_set(VALUE class, VALUE bool) {
|
445
|
+
if (TYPE(bool) == T_FALSE) {
|
446
|
+
xmlLoadExtDtdDefaultValue = 0;
|
447
|
+
return(Qfalse);
|
448
|
+
} else {
|
449
|
+
xmlLoadExtDtdDefaultValue = 1;
|
450
|
+
return(Qtrue);
|
451
|
+
}
|
452
|
+
}
|
453
|
+
|
454
|
+
|
455
|
+
/*
|
456
|
+
* call-seq:
|
457
|
+
* XML.default_line_numbers -> (true|false)
|
458
|
+
*
|
459
|
+
* Determine whether parsers retain line-numbers by default.
|
460
|
+
*/
|
461
|
+
VALUE
|
462
|
+
ruby_xml_default_line_numbers_get(VALUE class) {
|
463
|
+
if (xmlLineNumbersDefaultValue)
|
464
|
+
return(Qtrue);
|
465
|
+
else
|
466
|
+
return(Qfalse);
|
467
|
+
}
|
468
|
+
|
469
|
+
|
470
|
+
/*
|
471
|
+
* call-seq:
|
472
|
+
* XML.default_line_numbers = true|false
|
473
|
+
*
|
474
|
+
* Controls whether parsers retain line-numbers by default.
|
475
|
+
*/
|
476
|
+
VALUE
|
477
|
+
ruby_xml_default_line_numbers_set(VALUE class, VALUE bool) {
|
478
|
+
if (TYPE(bool) == T_FALSE) {
|
479
|
+
xmlLineNumbersDefault(0);
|
480
|
+
return(Qfalse);
|
481
|
+
} else {
|
482
|
+
xmlLineNumbersDefault(1);
|
483
|
+
return(Qtrue);
|
484
|
+
}
|
485
|
+
}
|
486
|
+
|
487
|
+
|
488
|
+
/*
|
489
|
+
* call-seq:
|
490
|
+
* XML.default_pedantic_parser -> (true|false)
|
491
|
+
*
|
492
|
+
* Determine whether parsers are pedantic by default.
|
493
|
+
*/
|
494
|
+
VALUE
|
495
|
+
ruby_xml_default_pedantic_parser_get(VALUE class) {
|
496
|
+
if (xmlPedanticParserDefaultValue)
|
497
|
+
return(Qtrue);
|
498
|
+
else
|
499
|
+
return(Qfalse);
|
500
|
+
}
|
501
|
+
|
502
|
+
|
503
|
+
/*
|
504
|
+
* call-seq:
|
505
|
+
* XML.default_pedantic_parser = true|false
|
506
|
+
*
|
507
|
+
* Controls whether parsers are pedantic by default.
|
508
|
+
*/
|
509
|
+
VALUE
|
510
|
+
ruby_xml_default_pedantic_parser_set(VALUE class, VALUE bool) {
|
511
|
+
if (TYPE(bool) == T_FALSE) {
|
512
|
+
xmlPedanticParserDefault(0);
|
513
|
+
return(Qfalse);
|
514
|
+
} else {
|
515
|
+
xmlPedanticParserDefault(1);
|
516
|
+
return(Qtrue);
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
|
521
|
+
/*
|
522
|
+
* call-seq:
|
523
|
+
* XML.default_substitute_entities -> (true|false)
|
524
|
+
*
|
525
|
+
* Determine whether parsers perform inline entity substitution
|
526
|
+
* (for external entities) by default.
|
527
|
+
*/
|
528
|
+
VALUE
|
529
|
+
ruby_xml_default_substitute_entities_get(VALUE class) {
|
530
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
531
|
+
return(Qtrue);
|
532
|
+
else
|
533
|
+
return(Qfalse);
|
534
|
+
}
|
535
|
+
|
536
|
+
|
537
|
+
/*
|
538
|
+
* call-seq:
|
539
|
+
* XML.default_substitute_entities = true|false
|
540
|
+
*
|
541
|
+
* Controls whether parsers perform inline entity substitution
|
542
|
+
* (for external entities) by default.
|
543
|
+
*/
|
544
|
+
VALUE
|
545
|
+
ruby_xml_default_substitute_entities_set(VALUE class, VALUE bool) {
|
546
|
+
if (TYPE(bool) == T_FALSE) {
|
547
|
+
xmlSubstituteEntitiesDefault(0);
|
548
|
+
return(Qfalse);
|
549
|
+
} else {
|
550
|
+
xmlSubstituteEntitiesDefault(1);
|
551
|
+
return(Qtrue);
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
|
556
|
+
/*
|
557
|
+
* call-seq:
|
558
|
+
* XML.default_tree_indent_string -> "string"
|
559
|
+
*
|
560
|
+
* Obtain the default string used by parsers to indent the XML tree
|
561
|
+
* for output.
|
562
|
+
*/
|
563
|
+
VALUE
|
564
|
+
ruby_xml_default_tree_indent_string_get(VALUE class) {
|
565
|
+
if (xmlTreeIndentString == NULL)
|
566
|
+
return(Qnil);
|
567
|
+
else
|
568
|
+
return(rb_str_new2(xmlTreeIndentString));
|
569
|
+
}
|
570
|
+
|
571
|
+
|
572
|
+
/*
|
573
|
+
* call-seq:
|
574
|
+
* XML.default_tree_indent_string = "string"
|
575
|
+
*
|
576
|
+
* Set the default string used by parsers to indent the XML tree
|
577
|
+
* for output.
|
578
|
+
*/
|
579
|
+
VALUE
|
580
|
+
ruby_xml_default_tree_indent_string_set(VALUE class, VALUE string) {
|
581
|
+
Check_Type(string, T_STRING);
|
582
|
+
xmlTreeIndentString = xmlStrdup(StringValuePtr(string));
|
583
|
+
return(string);
|
584
|
+
}
|
585
|
+
|
586
|
+
|
587
|
+
/*
|
588
|
+
* call-seq:
|
589
|
+
* XML.default_validity_checking -> (true|false)
|
590
|
+
*
|
591
|
+
* Determine whether parsers perform XML validation by default.
|
592
|
+
*/
|
593
|
+
VALUE
|
594
|
+
ruby_xml_default_validity_checking_get(VALUE class) {
|
595
|
+
if (xmlDoValidityCheckingDefaultValue)
|
596
|
+
return(Qtrue);
|
597
|
+
else
|
598
|
+
return(Qfalse);
|
599
|
+
}
|
600
|
+
|
601
|
+
|
602
|
+
/*
|
603
|
+
* call-seq:
|
604
|
+
* XML.default_validity_checking = true|false
|
605
|
+
*
|
606
|
+
* Controls whether parsers perform XML validation by default.
|
607
|
+
*/
|
608
|
+
VALUE
|
609
|
+
ruby_xml_default_validity_checking_set(VALUE class, VALUE bool) {
|
610
|
+
if (TYPE(bool) == T_FALSE) {
|
611
|
+
xmlDoValidityCheckingDefaultValue = 0;
|
612
|
+
return(Qfalse);
|
613
|
+
} else {
|
614
|
+
xmlDoValidityCheckingDefaultValue = 1;
|
615
|
+
return(Qtrue);
|
616
|
+
}
|
617
|
+
}
|
29
618
|
|
619
|
+
|
620
|
+
/*
|
621
|
+
* call-seq:
|
622
|
+
* XML.default_warnings -> (true|false)
|
623
|
+
*
|
624
|
+
* Determine whether parsers output warnings by default.
|
625
|
+
*/
|
626
|
+
VALUE
|
627
|
+
ruby_xml_default_warnings_get(VALUE class) {
|
628
|
+
if (xmlGetWarningsDefaultValue)
|
629
|
+
return(Qtrue);
|
630
|
+
else
|
631
|
+
return(Qfalse);
|
632
|
+
}
|
633
|
+
|
634
|
+
|
635
|
+
/*
|
636
|
+
* call-seq:
|
637
|
+
* XML.default_warnings = true|false
|
638
|
+
*
|
639
|
+
* Controls whether parsers output warnings by default.
|
640
|
+
*/
|
641
|
+
VALUE
|
642
|
+
ruby_xml_default_warnings_set(VALUE class, VALUE bool) {
|
643
|
+
if (TYPE(bool) == T_FALSE) {
|
644
|
+
xmlGetWarningsDefaultValue = 0;
|
645
|
+
return(Qfalse);
|
646
|
+
} else {
|
647
|
+
xmlGetWarningsDefaultValue = 1;
|
648
|
+
return(Qtrue);
|
649
|
+
}
|
650
|
+
}
|
651
|
+
|
652
|
+
|
653
|
+
/*
|
654
|
+
* call-seq:
|
655
|
+
* XML.default_compression -> (true|false)
|
656
|
+
*
|
657
|
+
* Determine whether parsers use Zlib compression by default
|
658
|
+
* (requires libxml to be compiled with Zlib support).
|
659
|
+
*/
|
660
|
+
VALUE
|
661
|
+
ruby_xml_default_compression_get(VALUE class) {
|
662
|
+
#ifdef HAVE_ZLIB_H
|
663
|
+
return(INT2FIX(xmlGetCompressMode()));
|
664
|
+
#else
|
665
|
+
rb_warn("libxml was compiled without zlib support");
|
666
|
+
return(Qfalse);
|
667
|
+
#endif
|
668
|
+
}
|
669
|
+
|
670
|
+
|
671
|
+
/*
|
672
|
+
* call-seq:
|
673
|
+
* XML.default_compression = true|false
|
674
|
+
*
|
675
|
+
* Controls whether parsers use Zlib compression by default
|
676
|
+
* (requires libxml to be compiled with Zlib support).
|
677
|
+
*/
|
678
|
+
VALUE
|
679
|
+
ruby_xml_default_compression_set(VALUE class, VALUE num) {
|
680
|
+
#ifdef HAVE_ZLIB_H
|
681
|
+
Check_Type(num, T_FIXNUM);
|
682
|
+
xmlSetCompressMode(FIX2INT(num));
|
683
|
+
return(num);
|
684
|
+
#else
|
685
|
+
rb_warn("libxml was compiled without zlib support");
|
686
|
+
return(Qfalse);
|
687
|
+
#endif
|
688
|
+
}
|
689
|
+
|
690
|
+
|
691
|
+
/*
|
692
|
+
* call-seq:
|
693
|
+
* XML.features -> ["feature", ..., "feature"]
|
694
|
+
*
|
695
|
+
* Obtains an array of strings representing features supported
|
696
|
+
* (and enabled) by the installed libxml.
|
697
|
+
*/
|
698
|
+
VALUE
|
699
|
+
ruby_xml_features(VALUE class) {
|
700
|
+
VALUE arr, str;
|
701
|
+
int i, len = MAX_LIBXML_FEATURES_LEN;
|
702
|
+
char **list = NULL;
|
703
|
+
|
704
|
+
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
705
|
+
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
706
|
+
|
707
|
+
arr = rb_ary_new();
|
708
|
+
if (xmlGetFeaturesList(&len, (const char **)list) == -1)
|
709
|
+
return Qnil;
|
710
|
+
|
711
|
+
for (i = 0; i < len; i++) {
|
712
|
+
str = rb_str_new2((const char *)list[i]);
|
713
|
+
rb_gc_unregister_address(&str);
|
714
|
+
rb_ary_push(arr, str);
|
715
|
+
}
|
716
|
+
|
717
|
+
if (len == MAX_LIBXML_FEATURES_LEN)
|
718
|
+
rb_warn("Please contact libxml-devel@rubyforge.org and ask to have the \"MAX_LIBXML_FEATURES_LEN increased\" because you could possibly be seeing an incomplete list");
|
719
|
+
|
720
|
+
ruby_xfree(list);
|
721
|
+
return(arr);
|
722
|
+
}
|
723
|
+
|
724
|
+
|
725
|
+
/*
|
726
|
+
* call-seq:
|
727
|
+
* XML.indent_tree_output -> (true|false)
|
728
|
+
*
|
729
|
+
* Determines whether XML output will be indented
|
730
|
+
* (using the string supplied to +default_indent_tree_string+)
|
731
|
+
*/
|
732
|
+
VALUE
|
733
|
+
ruby_xml_indent_tree_output_get(VALUE class) {
|
734
|
+
if (xmlIndentTreeOutput)
|
735
|
+
return(Qtrue);
|
736
|
+
else
|
737
|
+
return(Qfalse);
|
738
|
+
}
|
739
|
+
|
740
|
+
|
741
|
+
/*
|
742
|
+
* call-seq:
|
743
|
+
* XML.indent_tree_output = true|false
|
744
|
+
*
|
745
|
+
* Controls whether XML output will be indented
|
746
|
+
* (using the string supplied to +default_indent_tree_string+)
|
747
|
+
*/
|
748
|
+
VALUE
|
749
|
+
ruby_xml_indent_tree_output_set(VALUE class, VALUE bool) {
|
750
|
+
if (TYPE(bool) == T_TRUE) {
|
751
|
+
xmlIndentTreeOutput = 1;
|
752
|
+
return(Qtrue);
|
753
|
+
} else if (TYPE(bool) == T_FALSE) {
|
754
|
+
xmlIndentTreeOutput = 0;
|
755
|
+
return(Qfalse);
|
756
|
+
} else {
|
757
|
+
rb_raise(rb_eArgError, "Invalid argument, must be boolean");
|
758
|
+
}
|
759
|
+
}
|
760
|
+
|
761
|
+
/*
|
762
|
+
* call-seq:
|
763
|
+
* XML.memory_dump -> (true|false)
|
764
|
+
*
|
765
|
+
* Perform a parser memory dump (requires memory debugging
|
766
|
+
* support in libxml).
|
767
|
+
*/
|
768
|
+
VALUE
|
769
|
+
ruby_xml_memory_dump(VALUE self) {
|
770
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
771
|
+
xmlMemoryDump();
|
772
|
+
return(Qtrue);
|
773
|
+
#else
|
774
|
+
rb_warn("libxml was compiled without memory debugging support");
|
775
|
+
return(Qfalse);
|
776
|
+
#endif
|
777
|
+
}
|
778
|
+
|
779
|
+
|
780
|
+
/*
|
781
|
+
* call-seq:
|
782
|
+
* XML.memory_used -> num_bytes
|
783
|
+
*
|
784
|
+
* Perform a parser memory dump (requires memory debugging
|
785
|
+
* support in libxml).
|
786
|
+
*/
|
787
|
+
VALUE
|
788
|
+
ruby_xml_memory_used(VALUE self) {
|
789
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
790
|
+
return(INT2NUM(xmlMemUsed()));
|
791
|
+
#else
|
792
|
+
rb_warn("libxml was compiled without memory debugging support");
|
793
|
+
return(Qfalse);
|
794
|
+
#endif
|
795
|
+
}
|
796
|
+
|
797
|
+
#if defined(_WIN32)
|
798
|
+
__declspec(dllexport)
|
799
|
+
#endif
|
800
|
+
void
|
801
|
+
Init_libxml_ruby(void) {
|
30
802
|
mLibXML = rb_define_module("LibXML");
|
31
803
|
mXML = rb_define_module_under(mLibXML, "XML");
|
32
|
-
eXMLError = rb_define_class_under(mXML, "Error", rb_eRuntimeError);
|
33
804
|
|
805
|
+
/* Constants */
|
806
|
+
rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
|
807
|
+
rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
808
|
+
rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
34
809
|
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*)XML_XML_NAMESPACE));
|
35
810
|
|
811
|
+
rb_define_module_function(mXML, "enabled_automata?", ruby_xml_enabled_automata_q, 0);
|
812
|
+
rb_define_module_function(mXML, "enabled_c14n?", ruby_xml_enabled_c14n_q, 0);
|
813
|
+
rb_define_module_function(mXML, "enabled_catalog?", ruby_xml_enabled_catalog_q, 0);
|
814
|
+
rb_define_module_function(mXML, "enabled_debug?", ruby_xml_enabled_debug_q, 0);
|
815
|
+
rb_define_module_function(mXML, "enabled_docbook?", ruby_xml_enabled_docbook_q, 0);
|
816
|
+
rb_define_module_function(mXML, "enabled_ftp?", ruby_xml_enabled_ftp_q, 0);
|
817
|
+
rb_define_module_function(mXML, "enabled_http?", ruby_xml_enabled_http_q, 0);
|
818
|
+
rb_define_module_function(mXML, "enabled_html?", ruby_xml_enabled_html_q, 0);
|
819
|
+
rb_define_module_function(mXML, "enabled_iconv?", ruby_xml_enabled_iconv_q, 0);
|
820
|
+
rb_define_module_function(mXML, "enabled_memory_debug?", ruby_xml_enabled_memory_debug_location_q, 0);
|
821
|
+
rb_define_module_function(mXML, "enabled_regexp?", ruby_xml_enabled_regexp_q, 0);
|
822
|
+
rb_define_module_function(mXML, "enabled_schemas?", ruby_xml_enabled_schemas_q, 0);
|
823
|
+
rb_define_module_function(mXML, "enabled_thread?", ruby_xml_enabled_thread_q, 0);
|
824
|
+
rb_define_module_function(mXML, "enabled_unicode?", ruby_xml_enabled_unicode_q, 0);
|
825
|
+
rb_define_module_function(mXML, "enabled_xinclude?", ruby_xml_enabled_xinclude_q, 0);
|
826
|
+
rb_define_module_function(mXML, "enabled_xpath?", ruby_xml_enabled_xpath_q, 0);
|
827
|
+
rb_define_module_function(mXML, "enabled_xpointer?", ruby_xml_enabled_xpointer_q, 0);
|
828
|
+
rb_define_module_function(mXML, "enabled_zlib?", ruby_xml_enabled_zlib_q, 0);
|
829
|
+
|
830
|
+
rb_define_module_function(mXML, "catalog_dump", ruby_xml_catalog_dump, 0);
|
831
|
+
rb_define_module_function(mXML, "catalog_remove", ruby_xml_catalog_remove, 1);
|
832
|
+
rb_define_module_function(mXML, "check_lib_versions", ruby_xml_check_lib_versions, 0);
|
833
|
+
rb_define_module_function(mXML, "debug_entities", ruby_xml_debug_entities_get, 0);
|
834
|
+
rb_define_module_function(mXML, "debug_entities=", ruby_xml_debug_entities_set, 1);
|
835
|
+
rb_define_module_function(mXML, "default_compression", ruby_xml_default_compression_get, 0);
|
836
|
+
rb_define_module_function(mXML, "default_compression=", ruby_xml_default_compression_set, 1);
|
837
|
+
rb_define_module_function(mXML, "default_keep_blanks", ruby_xml_default_keep_blanks_get, 0);
|
838
|
+
rb_define_module_function(mXML, "default_keep_blanks=", ruby_xml_default_keep_blanks_set, 1);
|
839
|
+
rb_define_module_function(mXML, "default_load_external_dtd", ruby_xml_default_load_external_dtd_get, 0);
|
840
|
+
rb_define_module_function(mXML, "default_load_external_dtd=", ruby_xml_default_load_external_dtd_set, 1);
|
841
|
+
rb_define_module_function(mXML, "default_line_numbers", ruby_xml_default_line_numbers_get, 0);
|
842
|
+
rb_define_module_function(mXML, "default_line_numbers=", ruby_xml_default_line_numbers_set, 1);
|
843
|
+
rb_define_module_function(mXML, "default_pedantic_parser", ruby_xml_default_pedantic_parser_get, 0);
|
844
|
+
rb_define_module_function(mXML, "default_pedantic_parser=", ruby_xml_default_pedantic_parser_set, 1);
|
845
|
+
rb_define_module_function(mXML, "default_substitute_entities", ruby_xml_default_substitute_entities_get, 0);
|
846
|
+
rb_define_module_function(mXML, "default_substitute_entities=", ruby_xml_default_substitute_entities_set, 1);
|
847
|
+
rb_define_module_function(mXML, "default_tree_indent_string", ruby_xml_default_tree_indent_string_get, 0);
|
848
|
+
rb_define_module_function(mXML, "default_tree_indent_string=", ruby_xml_default_tree_indent_string_set, 1);
|
849
|
+
rb_define_module_function(mXML, "default_validity_checking", ruby_xml_default_validity_checking_get, 0);
|
850
|
+
rb_define_module_function(mXML, "default_validity_checking=", ruby_xml_default_validity_checking_set, 1);
|
851
|
+
rb_define_module_function(mXML, "default_warnings", ruby_xml_default_warnings_get, 0);
|
852
|
+
rb_define_module_function(mXML, "default_warnings=", ruby_xml_default_warnings_set, 1);
|
853
|
+
rb_define_module_function(mXML, "features", ruby_xml_features, 0);
|
854
|
+
rb_define_module_function(mXML, "indent_tree_output", ruby_xml_indent_tree_output_get, 0);
|
855
|
+
rb_define_module_function(mXML, "indent_tree_output=", ruby_xml_indent_tree_output_set, 1);
|
856
|
+
rb_define_module_function(mXML, "memory_dump", ruby_xml_memory_dump, 0);
|
857
|
+
rb_define_module_function(mXML, "memory_used", ruby_xml_memory_used, 0);
|
858
|
+
|
859
|
+
/* Now initialize all the other modules */
|
860
|
+
ruby_init_xml_encoding();
|
861
|
+
ruby_init_xml_error();
|
862
|
+
ruby_init_xml_input();
|
36
863
|
ruby_init_state();
|
37
864
|
ruby_init_parser();
|
38
865
|
ruby_init_xml_parser_context();
|
866
|
+
ruby_init_xml_node();
|
39
867
|
ruby_init_xml_attributes();
|
40
868
|
ruby_init_xml_attr();
|
41
869
|
ruby_init_xml_document();
|
42
|
-
ruby_init_xml_node();
|
43
|
-
ruby_init_xml_node_set();
|
44
870
|
ruby_init_xml_ns();
|
45
871
|
ruby_init_xml_sax_parser();
|
46
872
|
ruby_init_xml_xinclude();
|
47
873
|
ruby_init_xml_xpath();
|
48
874
|
ruby_init_xml_xpath_context();
|
49
875
|
ruby_init_xml_xpointer();
|
50
|
-
ruby_init_xml_xpointer_context();
|
51
876
|
ruby_init_html_parser();
|
52
877
|
ruby_init_input_callbacks();
|
53
878
|
ruby_init_xml_dtd();
|
54
879
|
ruby_init_xml_schema();
|
55
880
|
ruby_init_xml_relaxng();
|
56
|
-
ruby_init_xml_reader();
|
881
|
+
ruby_init_xml_reader();
|
57
882
|
|
58
|
-
|
59
|
-
|
883
|
+
ruby_xml_default_substitute_entities_set(mXML, Qtrue);
|
884
|
+
ruby_xml_default_load_external_dtd_set(mXML, Qtrue);
|
60
885
|
}
|