coupa-libxml-ruby 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +488 -0
- data/LICENSE +22 -0
- data/README +161 -0
- data/Rakefile +188 -0
- data/doc/css/normal.css +182 -0
- data/doc/img/raze-tiny.png +0 -0
- data/doc/img/red-cube.jpg +0 -0
- data/doc/img/xml-ruby.png +0 -0
- data/doc/index.xml +43 -0
- data/doc/install.xml +77 -0
- data/doc/layout.rhtml +38 -0
- data/doc/layout.xsl +67 -0
- data/doc/license.xml +32 -0
- data/doc/log/changelog.xml +1324 -0
- data/doc/log/changelog.xsl +42 -0
- data/doc/rdoc/classes/LibXML.html +207 -0
- data/doc/rdoc/classes/LibXML/XML.html +407 -0
- data/doc/rdoc/classes/LibXML/XML/Attr.html +521 -0
- data/doc/rdoc/classes/LibXML/XML/AttrDecl.html +360 -0
- data/doc/rdoc/classes/LibXML/XML/Attributes.html +149 -0
- data/doc/rdoc/classes/LibXML/XML/Document.html +460 -0
- data/doc/rdoc/classes/LibXML/XML/Error.html +129 -0
- data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +263 -0
- data/doc/rdoc/classes/LibXML/XML/Namespace.html +248 -0
- data/doc/rdoc/classes/LibXML/XML/Namespaces.html +200 -0
- data/doc/rdoc/classes/LibXML/XML/Node.html +1351 -0
- data/doc/rdoc/classes/LibXML/XML/Parser.html +328 -0
- data/doc/rdoc/classes/LibXML/XML/Reader.html +172 -0
- data/doc/rdoc/classes/LibXML/XML/SaxParser.html +232 -0
- data/doc/rdoc/classes/LibXML/XML/SaxParser/Callbacks.html +506 -0
- data/doc/rdoc/classes/LibXML/XML/SaxParser/VerboseCallbacks.html +555 -0
- data/doc/rdoc/classes/LibXML/XML/XPath.html +111 -0
- data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +162 -0
- data/doc/rdoc/classes/cXMLDtd.html +114 -0
- data/doc/rdoc/classes/cXMLNode.html +114 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/CHANGES.html +794 -0
- data/doc/rdoc/files/LICENSE.html +131 -0
- data/doc/rdoc/files/README.html +343 -0
- data/doc/rdoc/files/ext/libxml/libxml_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_attr_decl_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_cbg_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_encoding_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_error_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_context_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_options_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_io_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_namespace_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_namespaces_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_options_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_sax2_handler_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_expression_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
- data/doc/rdoc/files/lib/libxml/attr_decl_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/attr_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/attributes_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/document_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/error_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/hpricot_rb.html +192 -0
- data/doc/rdoc/files/lib/libxml/html_parser_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/namespace_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/namespaces_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/node_rb.html +108 -0
- data/doc/rdoc/files/lib/libxml/ns_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/parser_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/properties_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/reader_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/sax_callbacks_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/sax_parser_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/tree_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/xpath_object_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml_rb.html +133 -0
- data/doc/rdoc/files/lib/xml/libxml_rb.html +124 -0
- data/doc/rdoc/files/lib/xml_rb.html +134 -0
- data/doc/rdoc/fr_class_index.html +46 -0
- data/doc/rdoc/fr_file_index.html +84 -0
- data/doc/rdoc/fr_method_index.html +155 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/ext/libxml/Makefile +157 -0
- data/ext/libxml/build.log +4 -0
- data/ext/libxml/extconf.h +5 -0
- data/ext/libxml/extconf.rb +278 -0
- data/ext/libxml/libxml.c +77 -0
- data/ext/libxml/libxml.o +0 -0
- data/ext/libxml/libxml_ruby.bundle +0 -0
- data/ext/libxml/mkmf.log +228 -0
- data/ext/libxml/ruby_libxml.h +93 -0
- data/ext/libxml/ruby_xml.c +893 -0
- data/ext/libxml/ruby_xml.h +10 -0
- data/ext/libxml/ruby_xml.o +0 -0
- data/ext/libxml/ruby_xml_attr.c +352 -0
- data/ext/libxml/ruby_xml_attr.h +14 -0
- data/ext/libxml/ruby_xml_attr.o +0 -0
- data/ext/libxml/ruby_xml_attr_decl.c +171 -0
- data/ext/libxml/ruby_xml_attr_decl.h +13 -0
- data/ext/libxml/ruby_xml_attr_decl.o +0 -0
- data/ext/libxml/ruby_xml_attributes.c +277 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_attributes.o +0 -0
- data/ext/libxml/ruby_xml_cbg.c +86 -0
- data/ext/libxml/ruby_xml_cbg.o +0 -0
- data/ext/libxml/ruby_xml_document.c +1006 -0
- data/ext/libxml/ruby_xml_document.c.old +936 -0
- data/ext/libxml/ruby_xml_document.h +17 -0
- data/ext/libxml/ruby_xml_document.o +0 -0
- data/ext/libxml/ruby_xml_dtd.c +257 -0
- data/ext/libxml/ruby_xml_dtd.h +9 -0
- data/ext/libxml/ruby_xml_dtd.o +0 -0
- data/ext/libxml/ruby_xml_encoding.c +134 -0
- data/ext/libxml/ruby_xml_encoding.h +12 -0
- data/ext/libxml/ruby_xml_encoding.o +0 -0
- data/ext/libxml/ruby_xml_error.c +1004 -0
- data/ext/libxml/ruby_xml_error.h +14 -0
- data/ext/libxml/ruby_xml_error.o +0 -0
- data/ext/libxml/ruby_xml_html_parser.c +92 -0
- data/ext/libxml/ruby_xml_html_parser.h +12 -0
- data/ext/libxml/ruby_xml_html_parser.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
- data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
- data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_input_cbg.c +191 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_input_cbg.o +0 -0
- data/ext/libxml/ruby_xml_io.c +30 -0
- data/ext/libxml/ruby_xml_io.h +9 -0
- data/ext/libxml/ruby_xml_io.o +0 -0
- data/ext/libxml/ruby_xml_namespace.c +170 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespace.o +0 -0
- data/ext/libxml/ruby_xml_namespaces.c +295 -0
- data/ext/libxml/ruby_xml_namespaces.h +11 -0
- data/ext/libxml/ruby_xml_namespaces.o +0 -0
- data/ext/libxml/ruby_xml_node.c +1386 -0
- data/ext/libxml/ruby_xml_node.h +13 -0
- data/ext/libxml/ruby_xml_node.o +0 -0
- data/ext/libxml/ruby_xml_parser.c +94 -0
- data/ext/libxml/ruby_xml_parser.h +14 -0
- data/ext/libxml/ruby_xml_parser.o +0 -0
- data/ext/libxml/ruby_xml_parser_context.c +982 -0
- data/ext/libxml/ruby_xml_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_parser_options.c +68 -0
- data/ext/libxml/ruby_xml_parser_options.h +14 -0
- data/ext/libxml/ruby_xml_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_reader.c +1002 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_reader.o +0 -0
- data/ext/libxml/ruby_xml_relaxng.c +111 -0
- data/ext/libxml/ruby_xml_relaxng.h +10 -0
- data/ext/libxml/ruby_xml_relaxng.o +0 -0
- data/ext/libxml/ruby_xml_sax2_handler.c +322 -0
- data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
- data/ext/libxml/ruby_xml_sax2_handler.o +0 -0
- data/ext/libxml/ruby_xml_sax_parser.c +137 -0
- data/ext/libxml/ruby_xml_sax_parser.h +12 -0
- data/ext/libxml/ruby_xml_sax_parser.o +0 -0
- data/ext/libxml/ruby_xml_schema.c +159 -0
- data/ext/libxml/ruby_xml_schema.h +11 -0
- data/ext/libxml/ruby_xml_schema.o +0 -0
- data/ext/libxml/ruby_xml_version.h +9 -0
- data/ext/libxml/ruby_xml_xinclude.c +18 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xinclude.o +0 -0
- data/ext/libxml/ruby_xml_xpath.c +107 -0
- data/ext/libxml/ruby_xml_xpath.h +12 -0
- data/ext/libxml/ruby_xml_xpath.o +0 -0
- data/ext/libxml/ruby_xml_xpath_context.c +387 -0
- data/ext/libxml/ruby_xml_xpath_context.h +11 -0
- data/ext/libxml/ruby_xml_xpath_context.o +0 -0
- data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
- data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
- data/ext/libxml/ruby_xml_xpath_expression.o +0 -0
- data/ext/libxml/ruby_xml_xpath_object.c +336 -0
- data/ext/libxml/ruby_xml_xpath_object.h +19 -0
- data/ext/libxml/ruby_xml_xpath_object.o +0 -0
- data/ext/libxml/ruby_xml_xpointer.c +101 -0
- data/ext/libxml/ruby_xml_xpointer.h +13 -0
- data/ext/libxml/ruby_xml_xpointer.o +0 -0
- data/ext/mingw/Rakefile +34 -0
- data/ext/mingw/build.rake +41 -0
- data/ext/vc/libxml_ruby.sln +26 -0
- data/lib/libxml.rb +30 -0
- data/lib/libxml/attr.rb +111 -0
- data/lib/libxml/attr_decl.rb +78 -0
- data/lib/libxml/attributes.rb +12 -0
- data/lib/libxml/document.rb +190 -0
- data/lib/libxml/error.rb +88 -0
- data/lib/libxml/hpricot.rb +76 -0
- data/lib/libxml/html_parser.rb +94 -0
- data/lib/libxml/namespace.rb +60 -0
- data/lib/libxml/namespaces.rb +36 -0
- data/lib/libxml/node.rb +385 -0
- data/lib/libxml/ns.rb +20 -0
- data/lib/libxml/parser.rb +365 -0
- data/lib/libxml/properties.rb +21 -0
- data/lib/libxml/reader.rb +27 -0
- data/lib/libxml/sax_callbacks.rb +178 -0
- data/lib/libxml/sax_parser.rb +56 -0
- data/lib/libxml/tree.rb +27 -0
- data/lib/libxml/xpath_object.rb +14 -0
- data/lib/xml.rb +14 -0
- data/lib/xml/libxml.rb +8 -0
- data/setup.rb +1585 -0
- data/test/etc_doc_to_s.rb +19 -0
- data/test/ets_doc_file.rb +15 -0
- data/test/ets_doc_to_s.rb +21 -0
- data/test/ets_gpx.rb +26 -0
- data/test/ets_node_gc.rb +21 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +9 -0
- data/test/model/atom.xml +13 -0
- data/test/model/bands.xml +5 -0
- data/test/model/books.xml +146 -0
- data/test/model/merge_bug_data.xml +58 -0
- data/test/model/ruby-lang.html +238 -0
- data/test/model/rubynet.xml +79 -0
- data/test/model/rubynet_project +1 -0
- data/test/model/shiporder.rnc +28 -0
- data/test/model/shiporder.rng +86 -0
- data/test/model/shiporder.xml +23 -0
- data/test/model/shiporder.xsd +31 -0
- data/test/model/soap.xml +27 -0
- data/test/model/xinclude.xml +5 -0
- data/test/tc_attr.rb +170 -0
- data/test/tc_attr_decl.rb +131 -0
- data/test/tc_attributes.rb +133 -0
- data/test/tc_deprecated_require.rb +11 -0
- data/test/tc_document.rb +113 -0
- data/test/tc_document_write.rb +118 -0
- data/test/tc_dtd.rb +123 -0
- data/test/tc_error.rb +136 -0
- data/test/tc_html_parser.rb +138 -0
- data/test/tc_namespace.rb +59 -0
- data/test/tc_namespaces.rb +174 -0
- data/test/tc_node.rb +181 -0
- data/test/tc_node_cdata.rb +49 -0
- data/test/tc_node_comment.rb +30 -0
- data/test/tc_node_copy.rb +40 -0
- data/test/tc_node_edit.rb +158 -0
- data/test/tc_node_text.rb +69 -0
- data/test/tc_node_write.rb +83 -0
- data/test/tc_node_xlink.rb +26 -0
- data/test/tc_parser.rb +330 -0
- data/test/tc_parser_context.rb +186 -0
- data/test/tc_properties.rb +36 -0
- data/test/tc_reader.rb +284 -0
- data/test/tc_relaxng.rb +51 -0
- data/test/tc_sax_parser.rb +274 -0
- data/test/tc_schema.rb +51 -0
- data/test/tc_traversal.rb +220 -0
- data/test/tc_xinclude.rb +19 -0
- data/test/tc_xml.rb +224 -0
- data/test/tc_xpath.rb +193 -0
- data/test/tc_xpath_context.rb +78 -0
- data/test/tc_xpath_expression.rb +35 -0
- data/test/tc_xpointer.rb +72 -0
- data/test/test_suite.rb +33 -0
- metadata +376 -0
data/test/tc_xinclude.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'xml'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestXInclude < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/xinclude.xml'))
|
7
|
+
assert_instance_of(XML::Document, @doc)
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
@doc = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_ruby_xml_xinclude
|
15
|
+
assert_equal(1, @doc.xinclude)
|
16
|
+
assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n <p>This libxml2 binding has the following project information:\n <code>This is some text to include in an xml file via XInclude.</code></p>\n</document>\n",
|
17
|
+
@doc.to_s)
|
18
|
+
end
|
19
|
+
end
|
data/test/tc_xml.rb
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
require 'xml'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class TestXml < Test::Unit::TestCase
|
6
|
+
# ----- Constants ------
|
7
|
+
def test_lib_versions
|
8
|
+
assert(XML.check_lib_versions)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_debug_entities
|
12
|
+
XML.debug_entities = false
|
13
|
+
assert(!XML.debug_entities)
|
14
|
+
|
15
|
+
XML.debug_entities = true
|
16
|
+
assert(XML.debug_entities)
|
17
|
+
|
18
|
+
XML.debug_entities = false
|
19
|
+
assert(!XML.debug_entities)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_default_compression
|
23
|
+
return unless XML.default_compression
|
24
|
+
|
25
|
+
0.upto(9) do |i|
|
26
|
+
XML.default_compression = i
|
27
|
+
assert_equal(i, XML.default_compression)
|
28
|
+
end
|
29
|
+
|
30
|
+
9.downto(0) do |i|
|
31
|
+
assert_equal(i, XML.default_compression = i)
|
32
|
+
assert_equal(i, XML.default_compression)
|
33
|
+
end
|
34
|
+
|
35
|
+
0.downto(-10) do |i|
|
36
|
+
assert_equal(i, XML.default_compression = i)
|
37
|
+
assert_equal(0, XML.default_compression)
|
38
|
+
end
|
39
|
+
|
40
|
+
10.upto(20) do |i|
|
41
|
+
assert_equal(i, XML.default_compression = i)
|
42
|
+
assert_equal(9, XML.default_compression)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_default_keep_blanks
|
47
|
+
XML.default_keep_blanks = false
|
48
|
+
assert(!XML.default_keep_blanks)
|
49
|
+
assert_equal(XML::Parser::Options::NOBLANKS, XML.default_options)
|
50
|
+
|
51
|
+
XML.default_keep_blanks = true
|
52
|
+
assert(XML.default_keep_blanks)
|
53
|
+
assert_equal(0, XML.default_options)
|
54
|
+
|
55
|
+
XML.default_keep_blanks = false
|
56
|
+
assert(!XML.default_keep_blanks)
|
57
|
+
|
58
|
+
# other tests depend on keeping blanks by default,
|
59
|
+
# which is the default default behaviour anyway.
|
60
|
+
XML.default_keep_blanks = true
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_default_line_numbers
|
64
|
+
XML.default_line_numbers = false
|
65
|
+
assert(!XML.default_line_numbers)
|
66
|
+
|
67
|
+
XML.default_line_numbers = true
|
68
|
+
assert(XML.default_line_numbers)
|
69
|
+
|
70
|
+
XML.default_line_numbers = false
|
71
|
+
assert(!XML.default_line_numbers)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_default_substitute_entities
|
75
|
+
XML.default_substitute_entities = false
|
76
|
+
assert(!XML.default_substitute_entities)
|
77
|
+
assert_equal(0, XML.default_options)
|
78
|
+
|
79
|
+
XML.default_substitute_entities = true
|
80
|
+
assert(XML.default_substitute_entities)
|
81
|
+
assert_equal(XML::Parser::Options::NOENT, XML.default_options)
|
82
|
+
|
83
|
+
XML.default_substitute_entities = false
|
84
|
+
assert(!XML.default_substitute_entities)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_default_tree_indent_string
|
88
|
+
s = XML.default_tree_indent_string
|
89
|
+
assert_instance_of(String, s)
|
90
|
+
assert_equal(' ', s)
|
91
|
+
XML.default_tree_indent_string = 'uga'
|
92
|
+
s = XML.default_tree_indent_string
|
93
|
+
assert_instance_of(String, s)
|
94
|
+
assert_equal('uga', s)
|
95
|
+
XML.default_tree_indent_string = ' '
|
96
|
+
s = XML.default_tree_indent_string
|
97
|
+
assert_instance_of(String, s)
|
98
|
+
assert_equal(' ', s)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_default_validity_checking
|
102
|
+
XML.default_validity_checking = false
|
103
|
+
assert(!XML.default_validity_checking)
|
104
|
+
assert_equal(0, XML.default_options)
|
105
|
+
|
106
|
+
XML.default_validity_checking = true
|
107
|
+
assert(XML.default_validity_checking)
|
108
|
+
assert_equal(XML::Parser::Options::DTDVALID, XML.default_options)
|
109
|
+
|
110
|
+
XML.default_validity_checking = false
|
111
|
+
assert(!XML.default_validity_checking)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_default_warnings
|
115
|
+
XML.default_warnings = false
|
116
|
+
assert(!XML.default_warnings)
|
117
|
+
assert_equal(XML::Parser::Options::NOWARNING, XML.default_options)
|
118
|
+
|
119
|
+
XML.default_warnings = true
|
120
|
+
assert(XML.default_warnings)
|
121
|
+
assert_equal(0, XML.default_options)
|
122
|
+
|
123
|
+
XML.default_warnings = false
|
124
|
+
assert(!XML.default_warnings)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_enabled_automata
|
128
|
+
assert_equal(true, XML.enabled_automata?)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_enabled_c14n
|
132
|
+
assert_equal(true, XML.enabled_c14n?)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_enabled_catalog
|
136
|
+
assert_equal(true, XML.enabled_catalog?)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_enabled_debug
|
140
|
+
assert_equal(true, XML.enabled_debug?)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_enabled_docbook
|
144
|
+
assert_equal(true, XML.enabled_docbook?)
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_enabled_ftp
|
148
|
+
assert_equal(true, XML.enabled_ftp?)
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_enabled_http
|
152
|
+
assert_equal(true, XML.enabled_http?)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_enabled_html
|
156
|
+
assert_equal(true, XML.enabled_html?)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_enabled_iconv
|
160
|
+
assert_equal(true, XML.enabled_iconv?)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_enabled_memory_debug
|
164
|
+
assert_equal(false, XML.enabled_memory_debug?)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_enabled_regexp
|
168
|
+
assert_equal(true, XML.enabled_regexp?)
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_enabled_schemas
|
172
|
+
assert_equal(true, XML.enabled_schemas?)
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_enabled_thread
|
176
|
+
assert_equal(true, XML.enabled_thread?)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_enabled_unicode
|
180
|
+
assert_equal(true, XML.enabled_unicode?)
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_enabled_xinclude
|
184
|
+
assert_equal(true, XML.enabled_xinclude?)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_enabled_xpath
|
188
|
+
assert_equal(true, XML.enabled_xpath?)
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_enabled_xpointer
|
192
|
+
assert_equal(true, XML.enabled_xpointer?)
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_enabled_zlib
|
196
|
+
assert_equal(true, XML.enabled_zlib?)
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_intent_tree_output
|
200
|
+
assert(TrueClass, XML.indent_tree_output)
|
201
|
+
|
202
|
+
XML.indent_tree_output = false
|
203
|
+
assert(FalseClass, XML.indent_tree_output)
|
204
|
+
|
205
|
+
XML.indent_tree_output = true
|
206
|
+
assert(TrueClass, XML.indent_tree_output)
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_version
|
210
|
+
assert_instance_of(String, XML::VERSION)
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_vernum
|
214
|
+
assert_instance_of(Fixnum, XML::VERNUM)
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_libxml_parser_features
|
218
|
+
assert_instance_of(Array, XML.features)
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_default_options
|
222
|
+
assert_equal(0, XML.default_options)
|
223
|
+
end
|
224
|
+
end
|
data/test/tc_xpath.rb
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'xml'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestXPath < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
@doc = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_doc_find
|
15
|
+
nodes = @doc.find('/soap:Envelope')
|
16
|
+
assert_instance_of(XML::XPath::Object, nodes)
|
17
|
+
assert_equal(1, nodes.length)
|
18
|
+
assert_equal(nodes.xpath_type, XML::XPath::NODESET)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_doc_find_first
|
22
|
+
node = @doc.find_first('/soap:Envelope/soap:Body')
|
23
|
+
assert_instance_of(XML::Node, node)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_ns
|
27
|
+
nodes = @doc.find('//ns1:IdAndName', 'ns1:http://domain.somewhere.com')
|
28
|
+
assert_equal(3, nodes.length)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_ns_array
|
32
|
+
nodes = @doc.find('//ns1:IdAndName', ['ns1:http://domain.somewhere.com'])
|
33
|
+
assert_equal(3, nodes.length)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_default_ns1
|
37
|
+
# Find all nodes with http://services.somewhere.com namespace
|
38
|
+
nodes = @doc.find('//*[namespace-uri()="http://services.somewhere.com"]')
|
39
|
+
assert_equal(2, nodes.length)
|
40
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
41
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_default_ns2
|
45
|
+
# Find all nodes with http://services.somewhere.com namespace
|
46
|
+
nodes = @doc.find('//ns:*', 'ns:http://services.somewhere.com')
|
47
|
+
assert_equal(2, nodes.length)
|
48
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
49
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
50
|
+
|
51
|
+
# Get getManufacturerNamesResponse node
|
52
|
+
nodes = @doc.find('//ns:getManufacturerNamesResponse', 'ns:http://services.somewhere.com')
|
53
|
+
assert_equal(1, nodes.length)
|
54
|
+
|
55
|
+
# Get IdAndName node
|
56
|
+
nodes = @doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
|
57
|
+
['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
|
58
|
+
assert_equal(3, nodes.length)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_default_ns3
|
62
|
+
# Find all nodes with http://services.somewhere.com namespace
|
63
|
+
nodes = @doc.find('//ns:*', 'ns' => 'http://services.somewhere.com')
|
64
|
+
assert_equal(2, nodes.length)
|
65
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
66
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_default_ns4
|
70
|
+
# Find all nodes with http://services.somewhere.com namespace
|
71
|
+
nodes = @doc.find('//ns:*', :ns => 'http://services.somewhere.com')
|
72
|
+
assert_equal(2, nodes.length)
|
73
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
74
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_default_ns5
|
78
|
+
# Find all nodes with http://services.somewhere.com namespace
|
79
|
+
XML::Namespace.new(@doc.root, 'ns', 'http://services.somewhere.com')
|
80
|
+
nodes = @doc.find('//ns:*')
|
81
|
+
assert_equal(2, nodes.length)
|
82
|
+
assert_equal('getManufacturerNamesResponse', nodes[0].name)
|
83
|
+
assert_equal('IDAndNameList', nodes[1].name)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_attribute_ns
|
87
|
+
# Pull all nodes with http://services.somewhere.com namespace
|
88
|
+
nodes = @doc.find('@soap:encodingStyle')
|
89
|
+
assert_equal(1, nodes.length)
|
90
|
+
assert_equal('encodingStyle', nodes.first.name)
|
91
|
+
assert_equal('http://www.w3.org/2001/12/soap-encoding', nodes.first.value)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_register_default_ns
|
95
|
+
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/atom.xml'))
|
96
|
+
|
97
|
+
# No namespace has been yet defined
|
98
|
+
assert_raise(XML::Error) do
|
99
|
+
node = doc.find("atom:title")
|
100
|
+
end
|
101
|
+
|
102
|
+
node = doc.find('atom:title', 'atom:http://www.w3.org/2005/Atom')
|
103
|
+
assert_not_nil(node)
|
104
|
+
|
105
|
+
# Register namespace
|
106
|
+
doc.root.namespaces.default_prefix = 'atom'
|
107
|
+
node = doc.find("atom:title")
|
108
|
+
assert_not_nil(node)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_node_find
|
112
|
+
nodes = @doc.find('//ns1:IdAndName', 'ns1:http://domain.somewhere.com')
|
113
|
+
node = nodes.first
|
114
|
+
|
115
|
+
# Since we are searching on the node, don't have to register namespace
|
116
|
+
nodes = node.find('ns1:name')
|
117
|
+
assert_equal(1, nodes.length)
|
118
|
+
assert_equal(nodes.first.object_id, nodes.last.object_id, 'First and last should be the same')
|
119
|
+
assert_equal('name', nodes.first.name)
|
120
|
+
assert_equal('man1', nodes.first.content)
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_node_find_first
|
124
|
+
node = @doc.find_first('//ns1:IdAndName', 'ns1:http://domain.somewhere.com')
|
125
|
+
|
126
|
+
# Since we are searching on the node, don't have to register namespace
|
127
|
+
node = node.find_first('ns1:name')
|
128
|
+
assert_equal('name', node.name)
|
129
|
+
assert_equal('man1', node.content)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_node_no_doc
|
133
|
+
node = XML::Node.new('header', 'some content')
|
134
|
+
assert_raise(TypeError) do
|
135
|
+
node = node.find_first('/header')
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_memory
|
140
|
+
# This sometimes causes a segmentation fault because
|
141
|
+
# an xml document is sometimes freed before the
|
142
|
+
# xpath_object used to query it. When the xpath_object
|
143
|
+
# is free, it iterates over its results which are pointers
|
144
|
+
# to the document's nodes. A segmentation fault then happens.
|
145
|
+
|
146
|
+
1000.times do
|
147
|
+
doc = XML::Document.new('1.0')
|
148
|
+
doc.root = XML::Node.new("header")
|
149
|
+
|
150
|
+
1000.times do
|
151
|
+
doc.root << XML::Node.new("footer")
|
152
|
+
end
|
153
|
+
|
154
|
+
nodes = doc.find('/header/footer')
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Test that document doesn't get freed before nodes
|
159
|
+
def test_xpath_free
|
160
|
+
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
161
|
+
nodes = doc.find('//*')
|
162
|
+
GC.start
|
163
|
+
assert_equal('Envelope', nodes.first.name)
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_xpath_namespace_nodes
|
167
|
+
doc = XML::Document.string('<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml"><entry/></feed>')
|
168
|
+
nodes = doc.find('//atom:entry|namespace::*', :atom => "http://www.w3.org/2005/Atom")
|
169
|
+
assert_equal(4, nodes.length)
|
170
|
+
|
171
|
+
node = nodes[0]
|
172
|
+
assert_equal(XML::Node::ELEMENT_NODE, node.node_type)
|
173
|
+
|
174
|
+
node = nodes[1]
|
175
|
+
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
176
|
+
|
177
|
+
node = nodes[2]
|
178
|
+
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
179
|
+
|
180
|
+
node = nodes[3]
|
181
|
+
assert_equal(XML::Node::NAMESPACE_DECL, node.node_type)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Test to make sure we don't get nil on empty results.
|
185
|
+
# This is also to test that we don't segfault due to our C code getting a NULL pointer
|
186
|
+
# and not handling it properly.
|
187
|
+
def test_xpath_empty_result
|
188
|
+
doc = XML::Document.string('<html><body><p>Welcome to XHTML land!</p></body></html>')
|
189
|
+
nodes = doc.find("//object/param[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'wmode']")
|
190
|
+
assert_not_nil nodes
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'xml'
|
2
|
+
require "tempfile"
|
3
|
+
require "test/unit"
|
4
|
+
|
5
|
+
class TestXPathContext < Test::Unit::TestCase
|
6
|
+
SOAP_PREFIX = 'soap'
|
7
|
+
SOAP_URI = 'http://schemas.xmlsoap.org/soap/envelope/'
|
8
|
+
|
9
|
+
NS0_PREFIX = 'ns0'
|
10
|
+
NS0_URI = 'http://services.somewhere.com'
|
11
|
+
|
12
|
+
def setup
|
13
|
+
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
14
|
+
@context = XML::XPath::Context.new(doc)
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown()
|
18
|
+
@context = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
#def test_no_ns
|
22
|
+
#assert_raise(XML::XPath::InvalidPath) do
|
23
|
+
#@context.find('/soap:Envelope')
|
24
|
+
#end
|
25
|
+
#end
|
26
|
+
|
27
|
+
def test_ns_register
|
28
|
+
@context.register_namespace(SOAP_PREFIX, SOAP_URI)
|
29
|
+
@context.register_namespace(NS0_PREFIX, NS0_URI)
|
30
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
31
|
+
assert_equal(1, nodes.length)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_ns_register_string
|
35
|
+
@context.register_namespaces("#{SOAP_PREFIX}:#{SOAP_URI}")
|
36
|
+
@context.register_namespaces("#{NS0_PREFIX}:#{NS0_URI}")
|
37
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
38
|
+
assert_equal(1, nodes.length)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_ns_register_array
|
42
|
+
@context.register_namespaces(["#{SOAP_PREFIX}:#{SOAP_URI}", "#{NS0_PREFIX}:#{NS0_URI}"])
|
43
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
44
|
+
assert_equal(1, nodes.length)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_ns_register_hash
|
48
|
+
@context.register_namespaces(SOAP_PREFIX => SOAP_URI,
|
49
|
+
NS0_PREFIX => NS0_URI)
|
50
|
+
|
51
|
+
nodes = @context.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse')
|
52
|
+
assert_equal(1, nodes.length)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_ns_register_node
|
56
|
+
@context.register_namespaces_from_node(@context.doc.root)
|
57
|
+
nodes = @context.find('/soap:Envelope')
|
58
|
+
assert_equal(1, nodes.length)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_node
|
62
|
+
@context.register_namespaces_from_node(@context.doc.root)
|
63
|
+
|
64
|
+
nodes = @context.find('soap:Body')
|
65
|
+
assert_equal(0, nodes.length)
|
66
|
+
|
67
|
+
|
68
|
+
@context.node = @context.doc.root.child.next
|
69
|
+
nodes = @context.find('soap:Body')
|
70
|
+
assert_equal(0, nodes.length)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_cache
|
74
|
+
@context.enable_cache
|
75
|
+
@context.enable_cache(10)
|
76
|
+
@context.disable_cache
|
77
|
+
end
|
78
|
+
end
|