libxml-ruby 5.0.3 → 5.0.5
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.
- checksums.yaml +4 -4
- data/HISTORY +13 -2
- data/README.rdoc +1 -1
- data/ext/libxml/extconf.rb +5 -0
- data/ext/libxml/ruby_xml.c +556 -556
- data/ext/libxml/ruby_xml_attributes.h +17 -17
- data/ext/libxml/ruby_xml_document.c +1129 -1129
- data/ext/libxml/ruby_xml_dtd.c +257 -257
- data/ext/libxml/ruby_xml_encoding.c +250 -250
- data/ext/libxml/ruby_xml_error.c +1003 -1003
- data/ext/libxml/ruby_xml_error.h +14 -14
- data/ext/libxml/ruby_xml_html_parser_context.c +351 -351
- data/ext/libxml/ruby_xml_input_cbg.c +188 -188
- data/ext/libxml/ruby_xml_namespace.c +151 -151
- data/ext/libxml/ruby_xml_parser.h +10 -10
- data/ext/libxml/ruby_xml_parser_context.c +1009 -1009
- data/ext/libxml/ruby_xml_parser_options.c +74 -74
- data/ext/libxml/ruby_xml_parser_options.h +10 -10
- data/ext/libxml/ruby_xml_sax2_handler.c +326 -326
- data/ext/libxml/ruby_xml_sax_parser.c +108 -108
- data/ext/libxml/ruby_xml_version.h +9 -9
- data/ext/libxml/ruby_xml_writer.c +1124 -1138
- data/lib/libxml/attr.rb +122 -122
- data/lib/libxml/attr_decl.rb +80 -80
- data/lib/libxml/attributes.rb +13 -13
- data/lib/libxml/document.rb +194 -194
- data/lib/libxml/error.rb +95 -95
- data/lib/libxml/hpricot.rb +77 -77
- data/lib/libxml/html_parser.rb +96 -96
- data/lib/libxml/namespace.rb +61 -61
- data/lib/libxml/namespaces.rb +37 -37
- data/lib/libxml/node.rb +323 -323
- data/lib/libxml/parser.rb +102 -102
- data/lib/libxml/sax_callbacks.rb +179 -179
- data/lib/libxml/sax_parser.rb +40 -40
- data/lib/libxml/tree.rb +28 -28
- data/lib/libxml.rb +4 -4
- data/lib/xml/libxml.rb +10 -10
- data/lib/xml.rb +13 -13
- data/libxml-ruby.gemspec +50 -48
- data/test/test_document.rb +140 -140
- data/test/test_document_write.rb +142 -142
- data/test/test_dtd.rb +126 -126
- data/test/test_encoding.rb +126 -126
- data/test/test_error.rb +194 -194
- data/test/test_helper.rb +20 -20
- data/test/test_namespace.rb +58 -58
- data/test/test_node.rb +235 -235
- data/test/test_node_write.rb +93 -93
- data/test/test_parser.rb +333 -333
- data/test/test_reader.rb +364 -364
- data/test/test_sax_parser.rb +25 -6
- data/test/test_xml.rb +168 -168
- metadata +19 -8
data/lib/libxml/attr.rb
CHANGED
@@ -1,123 +1,123 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module LibXML
|
4
|
-
module XML
|
5
|
-
class Attr
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
# call-seq:
|
9
|
-
# attr.child? -> (true|false)
|
10
|
-
#
|
11
|
-
# Returns whether this attribute has child attributes.
|
12
|
-
#
|
13
|
-
def child?
|
14
|
-
not self.children.nil?
|
15
|
-
end
|
16
|
-
|
17
|
-
# call-seq:
|
18
|
-
# attr.doc? -> (true|false)
|
19
|
-
#
|
20
|
-
# Determine whether this attribute is associated with an
|
21
|
-
# XML::Document.
|
22
|
-
def doc?
|
23
|
-
not self.doc.nil?
|
24
|
-
end
|
25
|
-
|
26
|
-
# call-seq:
|
27
|
-
# attr.last? -> (true|false)
|
28
|
-
#
|
29
|
-
# Determine whether this is the last attribute.
|
30
|
-
def last?
|
31
|
-
self.last.nil?
|
32
|
-
end
|
33
|
-
|
34
|
-
# call-seq:
|
35
|
-
# attr.next? -> (true|false)
|
36
|
-
#
|
37
|
-
# Determine whether there is a next attribute.
|
38
|
-
def next?
|
39
|
-
not self.next.nil?
|
40
|
-
end
|
41
|
-
|
42
|
-
# call-seq:
|
43
|
-
# attr.ns? -> (true|false)
|
44
|
-
#
|
45
|
-
# Determine whether this attribute has an associated
|
46
|
-
# namespace.
|
47
|
-
def ns?
|
48
|
-
not self.ns.nil?
|
49
|
-
end
|
50
|
-
|
51
|
-
# call-seq:
|
52
|
-
# attr.namespacess -> XML::Namespaces
|
53
|
-
#
|
54
|
-
# Returns this node's XML::Namespaces object,
|
55
|
-
# which is used to access the namespaces
|
56
|
-
# associated with this node.
|
57
|
-
def namespaces
|
58
|
-
@namespaces ||= XML::Namespaces.new(self)
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
# call-seq:
|
63
|
-
# attr.parent? -> (true|false)
|
64
|
-
#
|
65
|
-
# Determine whether this attribute has a parent.
|
66
|
-
def parent?
|
67
|
-
not self.parent.nil?
|
68
|
-
end
|
69
|
-
|
70
|
-
# call-seq:
|
71
|
-
# attr.prev? -> (true|false)
|
72
|
-
#
|
73
|
-
# Determine whether there is a previous attribute.
|
74
|
-
def prev?
|
75
|
-
not self.prev.nil?
|
76
|
-
end
|
77
|
-
|
78
|
-
# Returns this node's type name
|
79
|
-
def node_type_name
|
80
|
-
if node_type == Node::ATTRIBUTE_NODE
|
81
|
-
'attribute'
|
82
|
-
else
|
83
|
-
raise(UnknownType, "Unknown node type: %n", node.node_type);
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# Iterates nodes and attributes
|
88
|
-
def siblings(node, &blk)
|
89
|
-
if n = node
|
90
|
-
loop do
|
91
|
-
blk.call(n)
|
92
|
-
break unless n = n.next
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def each_sibling(&blk)
|
98
|
-
siblings(self,&blk)
|
99
|
-
end
|
100
|
-
|
101
|
-
alias :each_attr :each_sibling
|
102
|
-
alias :each :each_sibling
|
103
|
-
|
104
|
-
def to_h
|
105
|
-
inject({}) do |h,a|
|
106
|
-
h[a.name] = a.value
|
107
|
-
h
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def to_a
|
112
|
-
inject([]) do |ary,a|
|
113
|
-
ary << [a.name, a.value]
|
114
|
-
ary
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def to_s
|
119
|
-
"#{name} = #{value}"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module LibXML
|
4
|
+
module XML
|
5
|
+
class Attr
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
# call-seq:
|
9
|
+
# attr.child? -> (true|false)
|
10
|
+
#
|
11
|
+
# Returns whether this attribute has child attributes.
|
12
|
+
#
|
13
|
+
def child?
|
14
|
+
not self.children.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
# call-seq:
|
18
|
+
# attr.doc? -> (true|false)
|
19
|
+
#
|
20
|
+
# Determine whether this attribute is associated with an
|
21
|
+
# XML::Document.
|
22
|
+
def doc?
|
23
|
+
not self.doc.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
# call-seq:
|
27
|
+
# attr.last? -> (true|false)
|
28
|
+
#
|
29
|
+
# Determine whether this is the last attribute.
|
30
|
+
def last?
|
31
|
+
self.last.nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
# call-seq:
|
35
|
+
# attr.next? -> (true|false)
|
36
|
+
#
|
37
|
+
# Determine whether there is a next attribute.
|
38
|
+
def next?
|
39
|
+
not self.next.nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
# call-seq:
|
43
|
+
# attr.ns? -> (true|false)
|
44
|
+
#
|
45
|
+
# Determine whether this attribute has an associated
|
46
|
+
# namespace.
|
47
|
+
def ns?
|
48
|
+
not self.ns.nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
# call-seq:
|
52
|
+
# attr.namespacess -> XML::Namespaces
|
53
|
+
#
|
54
|
+
# Returns this node's XML::Namespaces object,
|
55
|
+
# which is used to access the namespaces
|
56
|
+
# associated with this node.
|
57
|
+
def namespaces
|
58
|
+
@namespaces ||= XML::Namespaces.new(self)
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# call-seq:
|
63
|
+
# attr.parent? -> (true|false)
|
64
|
+
#
|
65
|
+
# Determine whether this attribute has a parent.
|
66
|
+
def parent?
|
67
|
+
not self.parent.nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
# call-seq:
|
71
|
+
# attr.prev? -> (true|false)
|
72
|
+
#
|
73
|
+
# Determine whether there is a previous attribute.
|
74
|
+
def prev?
|
75
|
+
not self.prev.nil?
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns this node's type name
|
79
|
+
def node_type_name
|
80
|
+
if node_type == Node::ATTRIBUTE_NODE
|
81
|
+
'attribute'
|
82
|
+
else
|
83
|
+
raise(UnknownType, "Unknown node type: %n", node.node_type);
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Iterates nodes and attributes
|
88
|
+
def siblings(node, &blk)
|
89
|
+
if n = node
|
90
|
+
loop do
|
91
|
+
blk.call(n)
|
92
|
+
break unless n = n.next
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def each_sibling(&blk)
|
98
|
+
siblings(self,&blk)
|
99
|
+
end
|
100
|
+
|
101
|
+
alias :each_attr :each_sibling
|
102
|
+
alias :each :each_sibling
|
103
|
+
|
104
|
+
def to_h
|
105
|
+
inject({}) do |h,a|
|
106
|
+
h[a.name] = a.value
|
107
|
+
h
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_a
|
112
|
+
inject([]) do |ary,a|
|
113
|
+
ary << [a.name, a.value]
|
114
|
+
ary
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def to_s
|
119
|
+
"#{name} = #{value}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
123
|
end
|
data/lib/libxml/attr_decl.rb
CHANGED
@@ -1,80 +1,80 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module LibXML
|
4
|
-
module XML
|
5
|
-
class AttrDecl
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
# call-seq:
|
9
|
-
# attr_decl.child -> nil
|
10
|
-
#
|
11
|
-
# Obtain this attribute declaration's child attribute(s).
|
12
|
-
# It will always be nil.
|
13
|
-
def child
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
|
17
|
-
# call-seq:
|
18
|
-
# attr_decl.child? -> (true|false)
|
19
|
-
#
|
20
|
-
# Returns whether this attribute declaration has child attributes.
|
21
|
-
#
|
22
|
-
def child?
|
23
|
-
not self.children.nil?
|
24
|
-
end
|
25
|
-
|
26
|
-
# call-seq:
|
27
|
-
# attr_decl.doc? -> (true|false)
|
28
|
-
#
|
29
|
-
# Determine whether this attribute declaration is associated with an
|
30
|
-
# XML::Document.
|
31
|
-
def doc?
|
32
|
-
not self.doc.nil?
|
33
|
-
end
|
34
|
-
|
35
|
-
# call-seq:
|
36
|
-
# attr_decl.next? -> (true|false)
|
37
|
-
#
|
38
|
-
# Determine whether there is a next attribute declaration.
|
39
|
-
def next?
|
40
|
-
not self.next.nil?
|
41
|
-
end
|
42
|
-
|
43
|
-
# call-seq:
|
44
|
-
# attr_decl.parent? -> (true|false)
|
45
|
-
#
|
46
|
-
# Determine whether this attribute declaration has a parent .
|
47
|
-
def parent?
|
48
|
-
not self.parent.nil?
|
49
|
-
end
|
50
|
-
|
51
|
-
# call-seq:
|
52
|
-
# attr_decl.prev? -> (true|false)
|
53
|
-
#
|
54
|
-
# Determine whether there is a previous attribute declaration.
|
55
|
-
def prev?
|
56
|
-
not self.prev.nil?
|
57
|
-
end
|
58
|
-
|
59
|
-
# call-seq:
|
60
|
-
# attr_decl.node_type_name -> 'attribute declaration'
|
61
|
-
#
|
62
|
-
# Returns this attribute declaration's node type name.
|
63
|
-
def node_type_name
|
64
|
-
if node_type == Node::ATTRIBUTE_DECL
|
65
|
-
'attribute declaration'
|
66
|
-
else
|
67
|
-
raise(UnknownType, "Unknown node type: %n", node.node_type);
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# call-seq:
|
72
|
-
# attr_decl.to_s -> string
|
73
|
-
#
|
74
|
-
# Returns a string representation of this attribute declaration.
|
75
|
-
def to_s
|
76
|
-
"#{name} = #{value}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module LibXML
|
4
|
+
module XML
|
5
|
+
class AttrDecl
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
# call-seq:
|
9
|
+
# attr_decl.child -> nil
|
10
|
+
#
|
11
|
+
# Obtain this attribute declaration's child attribute(s).
|
12
|
+
# It will always be nil.
|
13
|
+
def child
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
# call-seq:
|
18
|
+
# attr_decl.child? -> (true|false)
|
19
|
+
#
|
20
|
+
# Returns whether this attribute declaration has child attributes.
|
21
|
+
#
|
22
|
+
def child?
|
23
|
+
not self.children.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
# call-seq:
|
27
|
+
# attr_decl.doc? -> (true|false)
|
28
|
+
#
|
29
|
+
# Determine whether this attribute declaration is associated with an
|
30
|
+
# XML::Document.
|
31
|
+
def doc?
|
32
|
+
not self.doc.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
# call-seq:
|
36
|
+
# attr_decl.next? -> (true|false)
|
37
|
+
#
|
38
|
+
# Determine whether there is a next attribute declaration.
|
39
|
+
def next?
|
40
|
+
not self.next.nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
# call-seq:
|
44
|
+
# attr_decl.parent? -> (true|false)
|
45
|
+
#
|
46
|
+
# Determine whether this attribute declaration has a parent .
|
47
|
+
def parent?
|
48
|
+
not self.parent.nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
# call-seq:
|
52
|
+
# attr_decl.prev? -> (true|false)
|
53
|
+
#
|
54
|
+
# Determine whether there is a previous attribute declaration.
|
55
|
+
def prev?
|
56
|
+
not self.prev.nil?
|
57
|
+
end
|
58
|
+
|
59
|
+
# call-seq:
|
60
|
+
# attr_decl.node_type_name -> 'attribute declaration'
|
61
|
+
#
|
62
|
+
# Returns this attribute declaration's node type name.
|
63
|
+
def node_type_name
|
64
|
+
if node_type == Node::ATTRIBUTE_DECL
|
65
|
+
'attribute declaration'
|
66
|
+
else
|
67
|
+
raise(UnknownType, "Unknown node type: %n", node.node_type);
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# call-seq:
|
72
|
+
# attr_decl.to_s -> string
|
73
|
+
#
|
74
|
+
# Returns a string representation of this attribute declaration.
|
75
|
+
def to_s
|
76
|
+
"#{name} = #{value}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/libxml/attributes.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module LibXML
|
4
|
-
module XML
|
5
|
-
class Attributes
|
6
|
-
def to_h
|
7
|
-
inject({}) do |hash, attr|
|
8
|
-
hash[attr.name] = attr.value
|
9
|
-
hash
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module LibXML
|
4
|
+
module XML
|
5
|
+
class Attributes
|
6
|
+
def to_h
|
7
|
+
inject({}) do |hash, attr|
|
8
|
+
hash[attr.name] = attr.value
|
9
|
+
hash
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|