libxml-ruby 0.3.8.4 → 0.5.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.
- data/CHANGELOG +6 -0
- data/LICENSE +1 -1
- data/README +1 -1
- data/Rakefile +8 -5
- data/TODO +1 -1
- data/ext/xml/extconf.rb +4 -5
- data/ext/xml/libxml.c +5 -2
- data/ext/xml/libxml.h +16 -7
- data/ext/xml/libxml.rb +3 -3
- data/ext/xml/ruby_xml_attr.c +118 -99
- data/ext/xml/ruby_xml_attr.h +4 -7
- data/ext/xml/ruby_xml_document.c +131 -170
- data/ext/xml/ruby_xml_document.h +5 -9
- data/ext/xml/ruby_xml_html_parser.c +453 -0
- data/ext/xml/ruby_xml_html_parser.h +29 -0
- data/ext/xml/ruby_xml_node.c +219 -253
- data/ext/xml/ruby_xml_node.h +4 -7
- data/ext/xml/ruby_xml_node_set.c +6 -6
- data/ext/xml/ruby_xml_node_set.h +1 -1
- data/ext/xml/ruby_xml_ns.c +1 -1
- data/ext/xml/ruby_xml_ns.h +1 -1
- data/ext/xml/ruby_xml_parser.c +5 -8
- data/ext/xml/ruby_xml_parser.h +1 -1
- data/ext/xml/ruby_xml_parser_context.c +3 -4
- data/ext/xml/ruby_xml_parser_context.h +1 -1
- data/ext/xml/ruby_xml_reader.c +893 -0
- data/ext/xml/ruby_xml_reader.h +14 -0
- data/ext/xml/ruby_xml_sax_parser.c +255 -204
- data/ext/xml/ruby_xml_sax_parser.h +6 -2
- data/ext/xml/ruby_xml_tree.c +1 -1
- data/ext/xml/ruby_xml_tree.h +1 -1
- data/ext/xml/ruby_xml_xinclude.c +1 -1
- data/ext/xml/ruby_xml_xinclude.h +1 -1
- data/ext/xml/ruby_xml_xpath.c +3 -2
- data/ext/xml/ruby_xml_xpath.h +1 -1
- data/ext/xml/ruby_xml_xpath_context.c +4 -4
- data/ext/xml/ruby_xml_xpath_context.h +1 -1
- data/ext/xml/ruby_xml_xpointer.c +10 -4
- data/ext/xml/ruby_xml_xpointer.h +1 -1
- data/ext/xml/ruby_xml_xpointer_context.c +1 -1
- data/ext/xml/ruby_xml_xpointer_context.h +1 -1
- data/ext/xml/sax_parser_callbacks.inc +55 -54
- data/tests/model/rubynet_project +1 -1
- data/tests/model/simple.xml +7 -0
- data/tests/tc_xml_document.rb +1 -1
- data/tests/tc_xml_document_write.rb +1 -1
- data/tests/tc_xml_document_write2.rb +1 -1
- data/tests/tc_xml_document_write3.rb +1 -1
- data/tests/tc_xml_html_parser.rb +60 -0
- data/tests/tc_xml_node.rb +1 -1
- data/tests/tc_xml_node2.rb +1 -1
- data/tests/tc_xml_node3.rb +1 -1
- data/tests/tc_xml_node4.rb +8 -5
- data/tests/tc_xml_node5.rb +1 -1
- data/tests/tc_xml_node6.rb +1 -1
- data/tests/tc_xml_node7.rb +1 -1
- data/tests/tc_xml_node_set.rb +1 -1
- data/tests/tc_xml_node_set2.rb +1 -1
- data/tests/tc_xml_node_xlink.rb +1 -1
- data/tests/tc_xml_parser.rb +5 -1
- data/tests/tc_xml_parser2.rb +1 -1
- data/tests/tc_xml_parser3.rb +1 -1
- data/tests/tc_xml_parser4.rb +1 -1
- data/tests/tc_xml_parser5.rb +1 -1
- data/tests/tc_xml_parser6.rb +1 -1
- data/tests/tc_xml_parser7.rb +1 -1
- data/tests/tc_xml_parser8.rb +1 -1
- data/tests/tc_xml_parser_context.rb +1 -1
- data/tests/tc_xml_reader.rb +101 -0
- data/tests/tc_xml_sax_parser.rb +95 -0
- data/tests/tc_xml_xinclude.rb +1 -1
- data/tests/tc_xml_xpath.rb +1 -1
- data/tests/tc_xml_xpointer.rb +1 -1
- metadata +79 -73
- data/ext/xml/ruby_xml_attribute.c +0 -224
- data/ext/xml/ruby_xml_attribute.h +0 -21
- data/tests/test_xml_sax_parser.rb +0 -64
data/tests/tc_xml_parser4.rb
CHANGED
data/tests/tc_xml_parser5.rb
CHANGED
data/tests/tc_xml_parser6.rb
CHANGED
data/tests/tc_xml_parser7.rb
CHANGED
data/tests/tc_xml_parser8.rb
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require 'libxml_test'
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_XML_Reader < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
SIMPLE_XML = File.join(File.dirname(__FILE__), 'model/simple.xml')
|
|
7
|
+
|
|
8
|
+
def test_new_file
|
|
9
|
+
reader = XML::Reader.file(SIMPLE_XML)
|
|
10
|
+
do_test_simple(reader)
|
|
11
|
+
assert_raises(RuntimeError) { XML::Reader.file('/does/not/exist') }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_new_data
|
|
15
|
+
reader = XML::Reader.new(File.read(SIMPLE_XML))
|
|
16
|
+
do_test_simple(reader)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_new_walker
|
|
20
|
+
reader = XML::Reader.walker(XML::Document.file(SIMPLE_XML))
|
|
21
|
+
do_test_simple(reader)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_reader_error
|
|
25
|
+
reader = XML::Reader.new('<foo/>')
|
|
26
|
+
assert_raises(RuntimeError) { reader.set_error_handler }
|
|
27
|
+
called = false
|
|
28
|
+
reader.set_error_handler { |*a| called = true }
|
|
29
|
+
while reader.read > 0; end
|
|
30
|
+
assert(!called)
|
|
31
|
+
reader = XML::Reader.new('<foo blah')
|
|
32
|
+
reader.set_error_handler do |*a|
|
|
33
|
+
assert_equal(5, a.size)
|
|
34
|
+
assert_equal(reader, a[0])
|
|
35
|
+
assert_equal(XML::Reader::SEVERITY_ERROR, a[2])
|
|
36
|
+
assert_nil(a[3])
|
|
37
|
+
assert_equal(1, a[4])
|
|
38
|
+
called = true
|
|
39
|
+
end
|
|
40
|
+
while reader.read > 0; end
|
|
41
|
+
assert(called)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_attr
|
|
45
|
+
parser = XML::Reader.new("<foo x='1' y='2'/>")
|
|
46
|
+
assert_equal(1, parser.read)
|
|
47
|
+
assert_equal('foo', parser.name)
|
|
48
|
+
assert_equal('1', parser['x'])
|
|
49
|
+
assert_equal('1', parser[0])
|
|
50
|
+
assert_equal('2', parser['y'])
|
|
51
|
+
assert_equal('2', parser[1])
|
|
52
|
+
assert_equal(nil, parser['z'])
|
|
53
|
+
assert_equal(nil, parser[2])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_value
|
|
57
|
+
parser = XML::Reader.new("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
|
|
58
|
+
assert_equal(1, parser.read)
|
|
59
|
+
assert_equal('foo', parser.name)
|
|
60
|
+
assert_equal(nil, parser.value)
|
|
61
|
+
3.times do |i|
|
|
62
|
+
assert_equal(1, parser.read)
|
|
63
|
+
assert_equal(XML::Reader::TYPE_ELEMENT, parser.node_type)
|
|
64
|
+
assert_equal('bar', parser.name)
|
|
65
|
+
assert_equal(1, parser.read)
|
|
66
|
+
assert_equal(XML::Reader::TYPE_TEXT, parser.node_type)
|
|
67
|
+
assert_equal((i + 1).to_s, parser.value)
|
|
68
|
+
assert_equal(1, parser.read)
|
|
69
|
+
assert_equal(XML::Reader::TYPE_END_ELEMENT, parser.node_type)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def do_test_simple(reader)
|
|
74
|
+
node_types = []
|
|
75
|
+
19.times do
|
|
76
|
+
assert_equal(1, reader.read)
|
|
77
|
+
node_types << reader.node_type
|
|
78
|
+
end
|
|
79
|
+
assert_equal(0, reader.read)
|
|
80
|
+
assert_equal(node_types,
|
|
81
|
+
[XML::Reader::TYPE_ELEMENT,
|
|
82
|
+
XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
|
|
83
|
+
XML::Reader::TYPE_ELEMENT,
|
|
84
|
+
XML::Reader::TYPE_TEXT,
|
|
85
|
+
XML::Reader::TYPE_END_ELEMENT,
|
|
86
|
+
XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
|
|
87
|
+
XML::Reader::TYPE_ELEMENT,
|
|
88
|
+
XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
|
|
89
|
+
XML::Reader::TYPE_ELEMENT,
|
|
90
|
+
XML::Reader::TYPE_TEXT,
|
|
91
|
+
XML::Reader::TYPE_END_ELEMENT,
|
|
92
|
+
XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
|
|
93
|
+
XML::Reader::TYPE_ELEMENT,
|
|
94
|
+
XML::Reader::TYPE_TEXT,
|
|
95
|
+
XML::Reader::TYPE_END_ELEMENT,
|
|
96
|
+
XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
|
|
97
|
+
XML::Reader::TYPE_END_ELEMENT,
|
|
98
|
+
XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
|
|
99
|
+
XML::Reader::TYPE_END_ELEMENT])
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# $Id: tc_xml_sax_parser.rb 111 2006-11-20 01:39:14Z roscopeco $
|
|
2
|
+
require "libxml_test"
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
|
|
5
|
+
# TODO this is woefully inadequate
|
|
6
|
+
|
|
7
|
+
class TC_XML_SaxParser2 < Test::Unit::TestCase
|
|
8
|
+
class TestCaseCallbacks
|
|
9
|
+
include XML::SaxParser::Callbacks
|
|
10
|
+
|
|
11
|
+
attr_accessor :test
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
@test = Hash.new { |h,k| h[k] = [] }
|
|
15
|
+
@i = 0
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def on_start_document
|
|
19
|
+
@test[:startdoc] << @i+=1
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def on_start_element(name, attr_hash)
|
|
23
|
+
@test[:startel] << [@i+=1,name,attr_hash]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def on_characters(chars)
|
|
27
|
+
@test[:chars] << [@i+=1,chars]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def on_comment(msg)
|
|
31
|
+
@test[:comment] << [@i+=1,msg]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def on_processing_instruction(target, data)
|
|
35
|
+
@test[:pinstr] << [@i+=1, target, data]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def on_cdata_block(cdata)
|
|
39
|
+
@test[:cdata] << [@i+=1,cdata]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def on_end_element(name)
|
|
43
|
+
@test[:endel] << [@i+=1,name]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def on_end_document
|
|
47
|
+
@test[:enddoc] << @i+=1
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def setup()
|
|
52
|
+
@xp = XML::SaxParser.new
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def teardown()
|
|
56
|
+
@xp = nil
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_string_without_callbacks
|
|
60
|
+
@xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
|
|
61
|
+
assert_equal true, @xp.parse
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_file_without_callbacks
|
|
65
|
+
@xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
|
|
66
|
+
assert_equal true, @xp.parse
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_callbacks_with_string
|
|
70
|
+
@xp.callbacks = TestCaseCallbacks.new
|
|
71
|
+
@xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
|
|
72
|
+
do_test
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_callbacks_with_file
|
|
76
|
+
@xp.callbacks = TestCaseCallbacks.new
|
|
77
|
+
@xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
|
|
78
|
+
do_test
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def do_test
|
|
82
|
+
@xp.parse
|
|
83
|
+
|
|
84
|
+
assert_equal [1], @xp.callbacks.test[:startdoc]
|
|
85
|
+
assert_equal [[2,'test',{'uga'=>'booga','foo'=>'bar'}],[3,'fixnum',{}],[6,'fixnum',{}]],
|
|
86
|
+
@xp.callbacks.test[:startel]
|
|
87
|
+
assert_equal [[4,'one'],[7,'two'],[9,"\n "],[11,"\n "],[13,"\n "],[15,"\n"]],
|
|
88
|
+
@xp.callbacks.test[:chars]
|
|
89
|
+
assert_equal [[10, ' msg ']], @xp.callbacks.test[:comment]
|
|
90
|
+
assert_equal [[12, 'custom', 'foo="bar"']], @xp.callbacks.test[:pinstr]
|
|
91
|
+
assert_equal [[14, 'here it goes']], @xp.callbacks.test[:cdata]
|
|
92
|
+
assert_equal [[5,'fixnum'],[8,'fixnum'],[16,'test']], @xp.callbacks.test[:endel]
|
|
93
|
+
assert_equal [17], @xp.callbacks.test[:enddoc]
|
|
94
|
+
end
|
|
95
|
+
end # TC_XML_Sax_Parser
|
data/tests/tc_xml_xinclude.rb
CHANGED
data/tests/tc_xml_xpath.rb
CHANGED
data/tests/tc_xml_xpointer.rb
CHANGED
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.9.
|
|
2
|
+
rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: libxml-ruby
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.
|
|
7
|
-
date:
|
|
6
|
+
version: 0.5.0
|
|
7
|
+
date: 2007-08-30 00:00:00 -04:00
|
|
8
8
|
summary: LibXML2 bindings for Ruby
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -29,96 +29,101 @@ post_install_message:
|
|
|
29
29
|
authors:
|
|
30
30
|
- Sean Chittenden
|
|
31
31
|
files:
|
|
32
|
-
- ext/xml/libxml.rb
|
|
33
32
|
- ext/xml/extconf.rb
|
|
33
|
+
- ext/xml/libxml.rb
|
|
34
|
+
- CHANGELOG
|
|
35
|
+
- LICENSE
|
|
34
36
|
- Rakefile
|
|
35
37
|
- README
|
|
36
38
|
- TODO
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
- ext/xml/ruby_xml_xpath.c
|
|
40
|
-
- ext/xml/ruby_xml_node_set.c
|
|
39
|
+
- ext/xml/cbg.c
|
|
40
|
+
- ext/xml/libxml.c
|
|
41
41
|
- ext/xml/ruby_xml_attr.c
|
|
42
|
-
- ext/xml/ruby_xml_parser.c
|
|
43
|
-
- ext/xml/ruby_xml_node.c
|
|
44
42
|
- ext/xml/ruby_xml_document.c
|
|
45
43
|
- ext/xml/ruby_xml_dtd.c
|
|
46
|
-
- ext/xml/
|
|
47
|
-
- ext/xml/
|
|
48
|
-
- ext/xml/
|
|
44
|
+
- ext/xml/ruby_xml_html_parser.c
|
|
45
|
+
- ext/xml/ruby_xml_input_cbg.c
|
|
46
|
+
- ext/xml/ruby_xml_node.c
|
|
47
|
+
- ext/xml/ruby_xml_node_set.c
|
|
49
48
|
- ext/xml/ruby_xml_ns.c
|
|
50
|
-
- ext/xml/
|
|
51
|
-
- ext/xml/
|
|
49
|
+
- ext/xml/ruby_xml_parser.c
|
|
50
|
+
- ext/xml/ruby_xml_parser_context.c
|
|
51
|
+
- ext/xml/ruby_xml_reader.c
|
|
52
52
|
- ext/xml/ruby_xml_sax_parser.c
|
|
53
|
+
- ext/xml/ruby_xml_schema.c
|
|
53
54
|
- ext/xml/ruby_xml_tree.c
|
|
54
|
-
- ext/xml/ruby_xml_attribute.c
|
|
55
55
|
- ext/xml/ruby_xml_xinclude.c
|
|
56
|
+
- ext/xml/ruby_xml_xpath.c
|
|
56
57
|
- ext/xml/ruby_xml_xpath_context.c
|
|
57
|
-
- ext/xml/
|
|
58
|
-
- ext/xml/
|
|
58
|
+
- ext/xml/ruby_xml_xpointer.c
|
|
59
|
+
- ext/xml/ruby_xml_xpointer_context.c
|
|
59
60
|
- ext/xml/sax_parser_callbacks.inc
|
|
60
|
-
- ext/xml/
|
|
61
|
-
- ext/xml/
|
|
62
|
-
- ext/xml/
|
|
63
|
-
- ext/xml/
|
|
64
|
-
- ext/xml/ruby_xml_xpointer.h
|
|
61
|
+
- ext/xml/ruby_xml_attr.h
|
|
62
|
+
- ext/xml/ruby_xml_document.h
|
|
63
|
+
- ext/xml/ruby_xml_dtd.h
|
|
64
|
+
- ext/xml/ruby_xml_html_parser.h
|
|
65
65
|
- ext/xml/ruby_xml_input_cbg.h
|
|
66
|
-
- ext/xml/
|
|
67
|
-
- ext/xml/
|
|
66
|
+
- ext/xml/ruby_xml_node.h
|
|
67
|
+
- ext/xml/ruby_xml_node_set.h
|
|
68
68
|
- ext/xml/ruby_xml_ns.h
|
|
69
|
-
- ext/xml/
|
|
70
|
-
- ext/xml/
|
|
69
|
+
- ext/xml/ruby_xml_parser.h
|
|
70
|
+
- ext/xml/ruby_xml_parser_context.h
|
|
71
|
+
- ext/xml/ruby_xml_reader.h
|
|
71
72
|
- ext/xml/ruby_xml_sax_parser.h
|
|
72
|
-
- ext/xml/
|
|
73
|
-
- ext/xml/ruby_xml_dtd.h
|
|
74
|
-
- ext/xml/ruby_xml_attr.h
|
|
75
|
-
- ext/xml/ruby_xml_document.h
|
|
73
|
+
- ext/xml/ruby_xml_schema.h
|
|
76
74
|
- ext/xml/ruby_xml_tree.h
|
|
77
|
-
- ext/xml/
|
|
75
|
+
- ext/xml/ruby_xml_xinclude.h
|
|
76
|
+
- ext/xml/ruby_xml_xpath.h
|
|
77
|
+
- ext/xml/ruby_xml_xpath_context.h
|
|
78
|
+
- ext/xml/ruby_xml_xpointer.h
|
|
79
|
+
- ext/xml/ruby_xml_xpointer_context.h
|
|
78
80
|
- ext/xml/libxml.h
|
|
79
|
-
- tests/
|
|
80
|
-
- tests/tc_xml_node2.rb
|
|
81
|
-
- tests/tc_xml_node8.rb
|
|
81
|
+
- tests/copy_bug.rb
|
|
82
82
|
- tests/copy_bug2.rb
|
|
83
|
-
- tests/
|
|
84
|
-
- tests/
|
|
85
|
-
- tests/
|
|
83
|
+
- tests/dtd-test.rb
|
|
84
|
+
- tests/libxml_test.rb
|
|
85
|
+
- tests/merge_bug.rb
|
|
86
86
|
- tests/model
|
|
87
|
-
- tests/
|
|
88
|
-
- tests/
|
|
89
|
-
- tests/
|
|
87
|
+
- tests/model/default_validation_bug.rb
|
|
88
|
+
- tests/model/merge_bug_data.xml
|
|
89
|
+
- tests/model/rubynet.xml
|
|
90
|
+
- tests/model/rubynet_project
|
|
91
|
+
- tests/model/saxtest.xml
|
|
92
|
+
- tests/model/simple.xml
|
|
93
|
+
- tests/model/xinclude.xml
|
|
94
|
+
- tests/runner.rb
|
|
95
|
+
- tests/schema-test.rb
|
|
96
|
+
- tests/tc_xml_document.rb
|
|
97
|
+
- tests/tc_xml_document_write.rb
|
|
98
|
+
- tests/tc_xml_document_write2.rb
|
|
99
|
+
- tests/tc_xml_document_write3.rb
|
|
100
|
+
- tests/tc_xml_html_parser.rb
|
|
90
101
|
- tests/tc_xml_node.rb
|
|
102
|
+
- tests/tc_xml_node2.rb
|
|
103
|
+
- tests/tc_xml_node3.rb
|
|
91
104
|
- tests/tc_xml_node4.rb
|
|
92
|
-
- tests/
|
|
105
|
+
- tests/tc_xml_node5.rb
|
|
93
106
|
- tests/tc_xml_node6.rb
|
|
94
107
|
- tests/tc_xml_node7.rb
|
|
108
|
+
- tests/tc_xml_node8.rb
|
|
109
|
+
- tests/tc_xml_node9.rb
|
|
95
110
|
- tests/tc_xml_node_set.rb
|
|
96
|
-
- tests/
|
|
97
|
-
- tests/tc_xml_document_write2.rb
|
|
98
|
-
- tests/tc_xml_document_write.rb
|
|
99
|
-
- tests/tc_xml_document_write3.rb
|
|
111
|
+
- tests/tc_xml_node_set2.rb
|
|
100
112
|
- tests/tc_xml_node_xlink.rb
|
|
101
|
-
- tests/
|
|
102
|
-
- tests/
|
|
103
|
-
- tests/
|
|
104
|
-
- tests/
|
|
113
|
+
- tests/tc_xml_parser.rb
|
|
114
|
+
- tests/tc_xml_parser2.rb
|
|
115
|
+
- tests/tc_xml_parser3.rb
|
|
116
|
+
- tests/tc_xml_parser4.rb
|
|
105
117
|
- tests/tc_xml_parser5.rb
|
|
106
|
-
- tests/schema-test.rb
|
|
107
|
-
- tests/tc_xml_xpointer.rb
|
|
108
|
-
- tests/tc_xml_node_set2.rb
|
|
109
|
-
- tests/merge_bug.rb
|
|
110
|
-
- tests/tc_xml_document.rb
|
|
111
118
|
- tests/tc_xml_parser6.rb
|
|
112
|
-
- tests/copy_bug.rb
|
|
113
119
|
- tests/tc_xml_parser7.rb
|
|
120
|
+
- tests/tc_xml_parser8.rb
|
|
121
|
+
- tests/tc_xml_parser_context.rb
|
|
122
|
+
- tests/tc_xml_reader.rb
|
|
123
|
+
- tests/tc_xml_sax_parser.rb
|
|
124
|
+
- tests/tc_xml_xinclude.rb
|
|
114
125
|
- tests/tc_xml_xpath.rb
|
|
115
|
-
- tests/
|
|
116
|
-
- tests/model/rubynet_project
|
|
117
|
-
- tests/model/rubynet.xml
|
|
118
|
-
- tests/model/default_validation_bug.rb
|
|
119
|
-
- tests/model/saxtest.xml
|
|
120
|
-
- tests/model/xinclude.xml
|
|
121
|
-
- tests/model/merge_bug_data.xml
|
|
126
|
+
- tests/tc_xml_xpointer.rb
|
|
122
127
|
test_files:
|
|
123
128
|
- tests/runner.rb
|
|
124
129
|
rdoc_options:
|
|
@@ -130,24 +135,25 @@ extra_rdoc_files:
|
|
|
130
135
|
- README
|
|
131
136
|
- LICENSE
|
|
132
137
|
- TODO
|
|
133
|
-
- ext/xml/ruby_xml_xpath.c
|
|
134
|
-
- ext/xml/ruby_xml_node_set.c
|
|
135
138
|
- ext/xml/ruby_xml_attr.c
|
|
136
|
-
- ext/xml/ruby_xml_parser.c
|
|
137
|
-
- ext/xml/ruby_xml_node.c
|
|
138
139
|
- ext/xml/ruby_xml_document.c
|
|
139
140
|
- ext/xml/ruby_xml_dtd.c
|
|
140
|
-
- ext/xml/
|
|
141
|
-
- ext/xml/
|
|
142
|
-
- ext/xml/
|
|
141
|
+
- ext/xml/ruby_xml_html_parser.c
|
|
142
|
+
- ext/xml/ruby_xml_input_cbg.c
|
|
143
|
+
- ext/xml/ruby_xml_node.c
|
|
144
|
+
- ext/xml/ruby_xml_node_set.c
|
|
143
145
|
- ext/xml/ruby_xml_ns.c
|
|
144
|
-
- ext/xml/
|
|
146
|
+
- ext/xml/ruby_xml_parser.c
|
|
147
|
+
- ext/xml/ruby_xml_parser_context.c
|
|
148
|
+
- ext/xml/ruby_xml_reader.c
|
|
145
149
|
- ext/xml/ruby_xml_sax_parser.c
|
|
150
|
+
- ext/xml/ruby_xml_schema.c
|
|
146
151
|
- ext/xml/ruby_xml_tree.c
|
|
147
|
-
- ext/xml/ruby_xml_attribute.c
|
|
148
152
|
- ext/xml/ruby_xml_xinclude.c
|
|
153
|
+
- ext/xml/ruby_xml_xpath.c
|
|
149
154
|
- ext/xml/ruby_xml_xpath_context.c
|
|
150
|
-
- ext/xml/
|
|
155
|
+
- ext/xml/ruby_xml_xpointer.c
|
|
156
|
+
- ext/xml/ruby_xml_xpointer_context.c
|
|
151
157
|
- ext/xml/libxml.rb
|
|
152
158
|
executables: []
|
|
153
159
|
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
/* $Id: ruby_xml_attribute.c,v 1.2 2006/11/20 01:22:07 roscopeco Exp $ */
|
|
2
|
-
|
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
-
|
|
5
|
-
#include "libxml.h"
|
|
6
|
-
#include "ruby_xml_attribute.h"
|
|
7
|
-
|
|
8
|
-
VALUE cXMLAttribute;
|
|
9
|
-
|
|
10
|
-
// TODO Wtf is this about? It's not referenced outside this file AFAIK...
|
|
11
|
-
|
|
12
|
-
VALUE
|
|
13
|
-
ruby_xml_attribute_child_get(VALUE self) {
|
|
14
|
-
ruby_xml_attribute *rxa;
|
|
15
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
16
|
-
if (rxa->attribute->children == NULL)
|
|
17
|
-
return(Qnil);
|
|
18
|
-
else
|
|
19
|
-
return(ruby_xml_node_new_ptr(cXMLNode, rxa->xd, rxa->attribute->children));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
VALUE
|
|
24
|
-
ruby_xml_attribute_children_q(VALUE self) {
|
|
25
|
-
ruby_xml_attribute *rxa;
|
|
26
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
27
|
-
if (rxa->attribute->children == NULL)
|
|
28
|
-
return(Qfalse);
|
|
29
|
-
else
|
|
30
|
-
return(Qtrue);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
VALUE
|
|
35
|
-
ruby_xml_attribute_default_get(VALUE self) {
|
|
36
|
-
ruby_xml_attribute *rxa;
|
|
37
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
38
|
-
|
|
39
|
-
if (rxa->attribute->defaultValue == NULL)
|
|
40
|
-
return(Qnil);
|
|
41
|
-
else
|
|
42
|
-
return(rb_str_new2((const char*)rxa->attribute->defaultValue));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
VALUE
|
|
47
|
-
ruby_xml_attribute_element_get(VALUE self) {
|
|
48
|
-
ruby_xml_attribute *rxa;
|
|
49
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
50
|
-
|
|
51
|
-
if (rxa->attribute->elem == NULL)
|
|
52
|
-
return(Qnil);
|
|
53
|
-
else
|
|
54
|
-
return(rb_str_new2((const char*)rxa->attribute->elem));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
void
|
|
59
|
-
ruby_xml_attribute_free(ruby_xml_attribute *rxa) {
|
|
60
|
-
if (rxa->attribute != NULL && !rxa->is_ptr) {
|
|
61
|
-
xmlUnlinkNode((xmlNodePtr)rxa->attribute);
|
|
62
|
-
xmlFreeNode((xmlNodePtr)rxa->attribute);
|
|
63
|
-
rxa->attribute = NULL;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
free(rxa);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
VALUE
|
|
71
|
-
ruby_xml_attribute_last_get(VALUE self) {
|
|
72
|
-
ruby_xml_attribute *rxa;
|
|
73
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
74
|
-
if (rxa->attribute->last == NULL)
|
|
75
|
-
return(Qnil);
|
|
76
|
-
else
|
|
77
|
-
return(ruby_xml_node_new_ptr(cXMLNode, rxa->xd, rxa->attribute->last));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
VALUE
|
|
82
|
-
ruby_xml_attribute_last_q(VALUE self) {
|
|
83
|
-
ruby_xml_attribute *rxa;
|
|
84
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
85
|
-
if (rxa->attribute->last == NULL)
|
|
86
|
-
return(Qfalse);
|
|
87
|
-
else
|
|
88
|
-
return(Qtrue);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
static void
|
|
93
|
-
ruby_xml_attribute_mark(ruby_xml_attribute *rxa) {
|
|
94
|
-
if (rxa == NULL) return;
|
|
95
|
-
if (!NIL_P(rxa->xd)) rb_gc_mark(rxa->xd);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
VALUE
|
|
100
|
-
ruby_xml_attribute_name_get(VALUE self) {
|
|
101
|
-
ruby_xml_attribute *rxa;
|
|
102
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
103
|
-
|
|
104
|
-
if (rxa->attribute->name == NULL)
|
|
105
|
-
return(Qnil);
|
|
106
|
-
else
|
|
107
|
-
return(rb_str_new2((const char*)rxa->attribute->name));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
VALUE
|
|
112
|
-
ruby_xml_attribute_new(VALUE class, VALUE xd, xmlAttributePtr attribute) {
|
|
113
|
-
ruby_xml_attribute *rxa;
|
|
114
|
-
|
|
115
|
-
rxa = ALLOC(ruby_xml_attribute);
|
|
116
|
-
rxa->is_ptr = 0;
|
|
117
|
-
rxa->attribute = attribute;
|
|
118
|
-
if (NIL_P(xd))
|
|
119
|
-
rxa->xd = Qnil;
|
|
120
|
-
else
|
|
121
|
-
rxa->xd = xd;
|
|
122
|
-
return(Data_Wrap_Struct(class, ruby_xml_attribute_mark,
|
|
123
|
-
ruby_xml_attribute_free, rxa));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
VALUE
|
|
128
|
-
ruby_xml_attribute_new2(VALUE class, VALUE xd, xmlAttributePtr attribute) {
|
|
129
|
-
ruby_xml_attribute *rxa;
|
|
130
|
-
|
|
131
|
-
rxa = ALLOC(ruby_xml_attribute);
|
|
132
|
-
rxa->is_ptr = 1;
|
|
133
|
-
rxa->attribute = attribute;
|
|
134
|
-
if (NIL_P(xd))
|
|
135
|
-
rxa->xd = Qnil;
|
|
136
|
-
else
|
|
137
|
-
rxa->xd = xd;
|
|
138
|
-
return(Data_Wrap_Struct(class, ruby_xml_attribute_mark,
|
|
139
|
-
ruby_xml_attribute_free, rxa));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
VALUE
|
|
144
|
-
ruby_xml_attribute_next_get(VALUE self) {
|
|
145
|
-
ruby_xml_attribute *rxa;
|
|
146
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
147
|
-
if (rxa->attribute->next == NULL)
|
|
148
|
-
return(Qnil);
|
|
149
|
-
else
|
|
150
|
-
return(ruby_xml_node_new_ptr(cXMLNode, rxa->xd, rxa->attribute->next));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
VALUE
|
|
155
|
-
ruby_xml_attribute_next_q(VALUE self) {
|
|
156
|
-
ruby_xml_attribute *rxa;
|
|
157
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
158
|
-
if (rxa->attribute->next == NULL)
|
|
159
|
-
return(Qfalse);
|
|
160
|
-
else
|
|
161
|
-
return(Qtrue);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
VALUE
|
|
166
|
-
ruby_xml_attribute_node_type_name(VALUE self) {
|
|
167
|
-
return(rb_str_new2("attribute"));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
VALUE
|
|
172
|
-
ruby_xml_attribute_prefix_get(VALUE self) {
|
|
173
|
-
ruby_xml_attribute *rxa;
|
|
174
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
175
|
-
|
|
176
|
-
if (rxa->attribute->prefix == NULL)
|
|
177
|
-
return(Qnil);
|
|
178
|
-
else
|
|
179
|
-
return(rb_str_new2((const char*)rxa->attribute->prefix));
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
VALUE
|
|
184
|
-
ruby_xml_attribute_prev_get(VALUE self) {
|
|
185
|
-
ruby_xml_attribute *rxa;
|
|
186
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
187
|
-
if (rxa->attribute->prev == NULL)
|
|
188
|
-
return(Qnil);
|
|
189
|
-
else
|
|
190
|
-
return(ruby_xml_node_new_ptr(cXMLNode, rxa->xd, rxa->attribute->prev));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
VALUE
|
|
194
|
-
ruby_xml_attribute_prev_q(VALUE self) {
|
|
195
|
-
ruby_xml_attribute *rxa;
|
|
196
|
-
Data_Get_Struct(self, ruby_xml_attribute, rxa);
|
|
197
|
-
if (rxa->attribute->prev == NULL)
|
|
198
|
-
return(Qfalse);
|
|
199
|
-
else
|
|
200
|
-
return(Qtrue);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Rdoc maybe doesn't need to know
|
|
204
|
-
// #ifdef RDOC_NEVER_DEFINED
|
|
205
|
-
// mXML = rb_define_module("XML");
|
|
206
|
-
// #endif
|
|
207
|
-
|
|
208
|
-
void
|
|
209
|
-
ruby_init_xml_attribute(void) {
|
|
210
|
-
cXMLAttribute = rb_define_class_under(mXML, "Attribute", rb_cObject);
|
|
211
|
-
rb_define_method(cXMLAttribute, "child", ruby_xml_attribute_child_get, 0);
|
|
212
|
-
rb_define_method(cXMLAttribute, "children?", ruby_xml_attribute_children_q, 0);
|
|
213
|
-
rb_define_method(cXMLAttribute, "default", ruby_xml_attribute_default_get, 0);
|
|
214
|
-
rb_define_method(cXMLAttribute, "element", ruby_xml_attribute_element_get, 0);
|
|
215
|
-
rb_define_method(cXMLAttribute, "last", ruby_xml_attribute_last_get, 0);
|
|
216
|
-
rb_define_method(cXMLAttribute, "last?", ruby_xml_attribute_last_q, 0);
|
|
217
|
-
rb_define_method(cXMLAttribute, "node_type_name", ruby_xml_attribute_node_type_name, 0);
|
|
218
|
-
rb_define_method(cXMLAttribute, "name", ruby_xml_attribute_name_get, 0);
|
|
219
|
-
rb_define_method(cXMLAttribute, "next", ruby_xml_attribute_next_get, 0);
|
|
220
|
-
rb_define_method(cXMLAttribute, "next?", ruby_xml_attribute_next_q, 0);
|
|
221
|
-
rb_define_method(cXMLAttribute, "prefix", ruby_xml_attribute_prefix_get, 0);
|
|
222
|
-
rb_define_method(cXMLAttribute, "prev", ruby_xml_attribute_prev_get, 0);
|
|
223
|
-
rb_define_method(cXMLAttribute, "prev?", ruby_xml_attribute_prev_q, 0);
|
|
224
|
-
}
|