libxml-ruby 4.1.1-x64-mingw-ucrt → 5.0.0-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +22 -0
- data/ext/libxml/extconf.rb +67 -61
- data/ext/libxml/ruby_libxml.h +43 -44
- data/ext/libxml/ruby_xml.c +0 -343
- data/ext/libxml/ruby_xml.h +9 -10
- data/ext/libxml/ruby_xml_attr_decl.c +154 -153
- data/ext/libxml/ruby_xml_attributes.c +276 -275
- data/ext/libxml/ruby_xml_attributes.h +2 -0
- data/ext/libxml/ruby_xml_document.c +6 -6
- data/ext/libxml/ruby_xml_document.h +11 -11
- data/ext/libxml/ruby_xml_dtd.c +3 -3
- data/ext/libxml/ruby_xml_encoding.h +20 -18
- data/ext/libxml/ruby_xml_error.c +9 -6
- data/ext/libxml/ruby_xml_error.h +2 -2
- data/ext/libxml/ruby_xml_html_parser_context.c +35 -21
- data/ext/libxml/ruby_xml_namespace.c +0 -3
- data/ext/libxml/ruby_xml_node.c +1394 -1398
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +47 -39
- data/ext/libxml/ruby_xml_parser_options.c +9 -1
- data/ext/libxml/ruby_xml_parser_options.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +1244 -1242
- data/ext/libxml/ruby_xml_relaxng.c +113 -112
- data/ext/libxml/ruby_xml_sax2_handler.c +1 -1
- data/ext/libxml/ruby_xml_sax_parser.c +1 -9
- data/ext/libxml/ruby_xml_schema.c +422 -420
- data/ext/libxml/ruby_xml_schema_attribute.c +108 -107
- data/ext/libxml/ruby_xml_schema_element.c +70 -69
- data/ext/libxml/ruby_xml_schema_type.c +252 -251
- data/ext/libxml/ruby_xml_version.h +5 -5
- data/ext/libxml/ruby_xml_writer.c +1138 -1137
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +2 -2
- data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
- data/ext/libxml/ruby_xml_xpath_object.c +340 -339
- data/lib/3.2/libxml_ruby.so +0 -0
- data/lib/3.3/libxml_ruby.so +0 -0
- data/lib/libxml/document.rb +13 -13
- data/lib/libxml/html_parser.rb +23 -23
- data/lib/libxml/parser.rb +26 -24
- data/lib/libxml/schema/element.rb +27 -19
- data/test/test.rb +5 -0
- data/test/test_document_write.rb +1 -4
- data/test/test_dtd.rb +1 -4
- data/test/test_encoding.rb +1 -4
- data/test/test_helper.rb +9 -2
- data/test/test_html_parser.rb +162 -162
- data/test/test_namespace.rb +1 -3
- data/test/test_node.rb +1 -3
- data/test/test_node_write.rb +1 -4
- data/test/test_parser.rb +26 -17
- data/test/test_reader.rb +4 -4
- data/test/test_sax_parser.rb +1 -1
- data/test/test_schema.rb +237 -231
- data/test/test_xml.rb +0 -99
- metadata +5 -4
- data/lib/3.1/libxml_ruby.so +0 -0
data/lib/libxml/document.rb
CHANGED
@@ -17,21 +17,21 @@ module LibXML
|
|
17
17
|
|
18
18
|
# call-seq:
|
19
19
|
# XML::Document.file(path) -> XML::Document
|
20
|
-
# XML::Document.file(path, :
|
21
|
-
# :
|
20
|
+
# XML::Document.file(path, encoding: XML::Encoding::UTF_8,
|
21
|
+
# options: XML::Parser::Options::NOENT) -> XML::Document
|
22
22
|
#
|
23
23
|
# Creates a new document from the specified file or uri.
|
24
24
|
#
|
25
|
-
#
|
26
|
-
# parsing is performed. Valid options are:
|
25
|
+
# Parameters:
|
27
26
|
#
|
27
|
+
# path - Path to file
|
28
28
|
# encoding - The document encoding, defaults to nil. Valid values
|
29
29
|
# are the encoding constants defined on XML::Encoding.
|
30
30
|
# options - Parser options. Valid values are the constants defined on
|
31
31
|
# XML::Parser::Options. Mutliple options can be combined
|
32
32
|
# by using Bitwise OR (|).
|
33
|
-
def self.file(
|
34
|
-
Parser.file(
|
33
|
+
def self.file(path, encoding: nil, options: nil)
|
34
|
+
Parser.file(path, encoding: encoding, options: options).parse
|
35
35
|
end
|
36
36
|
|
37
37
|
# call-seq:
|
@@ -57,23 +57,23 @@ module LibXML
|
|
57
57
|
|
58
58
|
# call-seq:
|
59
59
|
# XML::Document.string(string) -> XML::Document
|
60
|
-
# XML::Document.string(string, :
|
61
|
-
#
|
62
|
-
#
|
60
|
+
# XML::Document.string(string, encoding: XML::Encoding::UTF_8,
|
61
|
+
# options: XML::Parser::Options::NOENT
|
62
|
+
# base_uri: "http://libxml.org") -> XML::Document
|
63
63
|
#
|
64
64
|
# Creates a new document from the specified string.
|
65
65
|
#
|
66
|
-
#
|
67
|
-
# parsing is performed. Valid options are:
|
66
|
+
# Parameters:
|
68
67
|
#
|
68
|
+
# string - String to parse
|
69
69
|
# base_uri - The base url for the parsed document.
|
70
70
|
# encoding - The document encoding, defaults to nil. Valid values
|
71
71
|
# are the encoding constants defined on XML::Encoding.
|
72
72
|
# options - Parser options. Valid values are the constants defined on
|
73
73
|
# XML::Parser::Options. Mutliple options can be combined
|
74
74
|
# by using Bitwise OR (|).
|
75
|
-
def self.string(value, options
|
76
|
-
Parser.string(value, options).parse
|
75
|
+
def self.string(value, base_uri: nil, encoding: nil, options: nil)
|
76
|
+
Parser.string(value, base_uri: base_uri, encoding: encoding, options: options).parse
|
77
77
|
end
|
78
78
|
|
79
79
|
# Returns a new XML::XPathContext for the document.
|
data/lib/libxml/html_parser.rb
CHANGED
@@ -5,31 +5,31 @@ module LibXML
|
|
5
5
|
class HTMLParser
|
6
6
|
# call-seq:
|
7
7
|
# XML::HTMLParser.file(path) -> XML::HTMLParser
|
8
|
-
# XML::HTMLParser.file(path, :
|
9
|
-
#
|
8
|
+
# XML::HTMLParser.file(path, encoding: XML::Encoding::UTF_8,
|
9
|
+
# options: XML::HTMLParser::Options::NOENT) -> XML::HTMLParser
|
10
10
|
#
|
11
11
|
# Creates a new parser by parsing the specified file or uri.
|
12
12
|
#
|
13
|
-
#
|
14
|
-
# parsing is performed. Valid options are:
|
13
|
+
# Parameters:
|
15
14
|
#
|
15
|
+
# path - Path to file to parse
|
16
16
|
# encoding - The document encoding, defaults to nil. Valid values
|
17
17
|
# are the encoding constants defined on XML::Encoding.
|
18
18
|
# options - Parser options. Valid values are the constants defined on
|
19
19
|
# XML::HTMLParser::Options. Mutliple options can be combined
|
20
20
|
# by using Bitwise OR (|).
|
21
|
-
def self.file(path, options
|
21
|
+
def self.file(path, encoding: nil, options: nil)
|
22
22
|
context = XML::HTMLParser::Context.file(path)
|
23
|
-
context.encoding =
|
24
|
-
context.options = options
|
23
|
+
context.encoding = encoding if encoding
|
24
|
+
context.options = options if options
|
25
25
|
self.new(context)
|
26
26
|
end
|
27
27
|
|
28
28
|
# call-seq:
|
29
29
|
# XML::HTMLParser.io(io) -> XML::HTMLParser
|
30
|
-
# XML::HTMLParser.io(io, :
|
31
|
-
#
|
32
|
-
#
|
30
|
+
# XML::HTMLParser.io(io, encoding: XML::Encoding::UTF_8,
|
31
|
+
# options: XML::HTMLParser::Options::NOENT
|
32
|
+
# base_uri: "http://libxml.org") -> XML::HTMLParser
|
33
33
|
#
|
34
34
|
# Creates a new reader by parsing the specified io object.
|
35
35
|
#
|
@@ -42,36 +42,36 @@ module LibXML
|
|
42
42
|
# options - Parser options. Valid values are the constants defined on
|
43
43
|
# XML::HTMLParser::Options. Mutliple options can be combined
|
44
44
|
# by using Bitwise OR (|).
|
45
|
-
def self.io(io, options
|
45
|
+
def self.io(io, base_uri: nil, encoding: nil, options: nil)
|
46
46
|
context = XML::HTMLParser::Context.io(io)
|
47
|
-
context.base_uri =
|
48
|
-
context.encoding =
|
49
|
-
context.options = options
|
47
|
+
context.base_uri = base_uri if base_uri
|
48
|
+
context.encoding = encoding if encoding
|
49
|
+
context.options = options if options
|
50
50
|
self.new(context)
|
51
51
|
end
|
52
52
|
|
53
53
|
# call-seq:
|
54
54
|
# XML::HTMLParser.string(string)
|
55
|
-
# XML::HTMLParser.string(string, :
|
56
|
-
#
|
57
|
-
#
|
55
|
+
# XML::HTMLParser.string(string, encoding: XML::Encoding::UTF_8,
|
56
|
+
# options: XML::HTMLParser::Options::NOENT
|
57
|
+
# base_uri: "http://libxml.org") -> XML::HTMLParser
|
58
58
|
#
|
59
59
|
# Creates a new parser by parsing the specified string.
|
60
60
|
#
|
61
|
-
#
|
62
|
-
# parsing is performed. Valid options are:
|
61
|
+
# Parameters:
|
63
62
|
#
|
63
|
+
# string - String to parse
|
64
64
|
# base_uri - The base url for the parsed document.
|
65
65
|
# encoding - The document encoding, defaults to nil. Valid values
|
66
66
|
# are the encoding constants defined on XML::Encoding.
|
67
67
|
# options - Parser options. Valid values are the constants defined on
|
68
68
|
# XML::HTMLParser::Options. Mutliple options can be combined
|
69
69
|
# by using Bitwise OR (|).
|
70
|
-
def self.string(string, options
|
70
|
+
def self.string(string, base_uri: nil, encoding: nil, options: nil)
|
71
71
|
context = XML::HTMLParser::Context.string(string)
|
72
|
-
context.base_uri =
|
73
|
-
context.encoding =
|
74
|
-
context.options = options
|
72
|
+
context.base_uri = base_uri if base_uri
|
73
|
+
context.encoding = encoding if encoding
|
74
|
+
context.options = options if options
|
75
75
|
self.new(context)
|
76
76
|
end
|
77
77
|
|
data/lib/libxml/parser.rb
CHANGED
@@ -18,31 +18,33 @@ module LibXML
|
|
18
18
|
|
19
19
|
# call-seq:
|
20
20
|
# XML::Parser.file(path) -> XML::Parser
|
21
|
-
# XML::Parser.file(path, :
|
22
|
-
# :
|
21
|
+
# XML::Parser.file(path, encoding: XML::Encoding::UTF_8,
|
22
|
+
# options: XML::Parser::Options::NOENT) -> XML::Parser
|
23
23
|
#
|
24
24
|
# Creates a new parser for the specified file or uri.
|
25
25
|
#
|
26
|
-
#
|
27
|
-
# parsing is performed. Valid options are:
|
26
|
+
# Parameters:
|
28
27
|
#
|
28
|
+
# path - Path to file
|
29
|
+
# base_uri - The base url for the parsed document.
|
29
30
|
# encoding - The document encoding, defaults to nil. Valid values
|
30
31
|
# are the encoding constants defined on XML::Encoding.
|
31
32
|
# options - Parser options. Valid values are the constants defined on
|
32
33
|
# XML::Parser::Options. Mutliple options can be combined
|
33
34
|
# by using Bitwise OR (|).
|
34
|
-
def self.file(path, options
|
35
|
+
def self.file(path, base_uri: nil, encoding: nil, options: nil)
|
35
36
|
context = XML::Parser::Context.file(path)
|
36
|
-
context.
|
37
|
-
context.
|
37
|
+
context.base_uri = base_uri if base_uri
|
38
|
+
context.encoding = encoding if encoding
|
39
|
+
context.options = options if options
|
38
40
|
self.new(context)
|
39
41
|
end
|
40
42
|
|
41
43
|
# call-seq:
|
42
44
|
# XML::Parser.io(io) -> XML::Parser
|
43
|
-
# XML::Parser.io(io, :
|
44
|
-
# :
|
45
|
-
# :
|
45
|
+
# XML::Parser.io(io, encoding: XML::Encoding::UTF_8,
|
46
|
+
# options: XML::Parser::Options::NOENT
|
47
|
+
# base_uri: "http://libxml.org") -> XML::Parser
|
46
48
|
#
|
47
49
|
# Creates a new parser for the specified io object.
|
48
50
|
#
|
@@ -55,36 +57,36 @@ module LibXML
|
|
55
57
|
# options - Parser options. Valid values are the constants defined on
|
56
58
|
# XML::Parser::Options. Mutliple options can be combined
|
57
59
|
# by using Bitwise OR (|).
|
58
|
-
def self.io(io, options
|
60
|
+
def self.io(io, base_uri: nil, encoding: nil, options: nil)
|
59
61
|
context = XML::Parser::Context.io(io)
|
60
|
-
context.base_uri =
|
61
|
-
context.encoding =
|
62
|
-
context.options = options
|
62
|
+
context.base_uri = base_uri if base_uri
|
63
|
+
context.encoding = encoding if encoding
|
64
|
+
context.options = options if options
|
63
65
|
self.new(context)
|
64
66
|
end
|
65
67
|
|
66
68
|
# call-seq:
|
67
69
|
# XML::Parser.string(string)
|
68
|
-
# XML::Parser.string(string, :
|
69
|
-
# :
|
70
|
-
# :
|
70
|
+
# XML::Parser.string(string, encoding: XML::Encoding::UTF_8,
|
71
|
+
# options: XML::Parser::Options::NOENT
|
72
|
+
# base_uri: "http://libxml.org") -> XML::Parser
|
71
73
|
#
|
72
74
|
# Creates a new parser by parsing the specified string.
|
73
75
|
#
|
74
|
-
#
|
75
|
-
# parsing is performed. Valid options are:
|
76
|
+
# Parameters:
|
76
77
|
#
|
78
|
+
# string - The string to parse
|
77
79
|
# base_uri - The base url for the parsed document.
|
78
80
|
# encoding - The document encoding, defaults to nil. Valid values
|
79
81
|
# are the encoding constants defined on XML::Encoding.
|
80
82
|
# options - Parser options. Valid values are the constants defined on
|
81
|
-
# XML::Parser::Options.
|
83
|
+
# XML::Parser::Options. Multiple options can be combined
|
82
84
|
# by using Bitwise OR (|).
|
83
|
-
def self.string(string, options
|
85
|
+
def self.string(string, base_uri: nil, encoding: nil, options: nil)
|
84
86
|
context = XML::Parser::Context.string(string)
|
85
|
-
context.base_uri =
|
86
|
-
context.encoding =
|
87
|
-
context.options = options
|
87
|
+
context.base_uri = base_uri if base_uri
|
88
|
+
context.encoding = encoding if encoding
|
89
|
+
context.options = options if options
|
88
90
|
self.new(context)
|
89
91
|
end
|
90
92
|
|
@@ -1,19 +1,27 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module LibXML
|
4
|
-
module XML
|
5
|
-
class Schema::Element
|
6
|
-
def
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module LibXML
|
4
|
+
module XML
|
5
|
+
class Schema::Element
|
6
|
+
def min_occurs
|
7
|
+
@min
|
8
|
+
end
|
9
|
+
|
10
|
+
def max_occurs
|
11
|
+
@max
|
12
|
+
end
|
13
|
+
|
14
|
+
def required?
|
15
|
+
!min_occurs.zero?
|
16
|
+
end
|
17
|
+
|
18
|
+
def array?
|
19
|
+
max_occurs > 1
|
20
|
+
end
|
21
|
+
|
22
|
+
def elements
|
23
|
+
type.elements
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/test/test.rb
ADDED
data/test/test_document_write.rb
CHANGED
@@ -7,14 +7,11 @@ class TestDocumentWrite < Minitest::Test
|
|
7
7
|
def setup
|
8
8
|
@file_name = "model/bands.utf-8.xml"
|
9
9
|
|
10
|
-
# Strip spaces to make testing easier
|
11
|
-
LibXML::XML.default_keep_blanks = false
|
12
10
|
file = File.join(File.dirname(__FILE__), @file_name)
|
13
|
-
@doc = LibXML::XML::Document.file(file)
|
11
|
+
@doc = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NOBLANKS)
|
14
12
|
end
|
15
13
|
|
16
14
|
def teardown
|
17
|
-
LibXML::XML.default_keep_blanks = true
|
18
15
|
@doc = nil
|
19
16
|
end
|
20
17
|
|
data/test/test_dtd.rb
CHANGED
@@ -106,13 +106,11 @@ class TestDtd < Minitest::Test
|
|
106
106
|
errors << error
|
107
107
|
end
|
108
108
|
|
109
|
-
LibXML::XML.default_load_external_dtd = false
|
110
109
|
LibXML::XML::Parser.string(xml).parse
|
111
110
|
assert_equal(0, errors.length)
|
112
111
|
|
113
112
|
errors.clear
|
114
|
-
LibXML::XML.
|
115
|
-
LibXML::XML::Parser.string(xml).parse
|
113
|
+
LibXML::XML::Parser.string(xml, options: LibXML::XML::Parser::Options::DTDLOAD).parse
|
116
114
|
assert_equal(1, errors.length)
|
117
115
|
assert_equal("Warning: failed to load external entity \"test.dtd\" at :1.",
|
118
116
|
errors[0].to_s)
|
@@ -123,7 +121,6 @@ class TestDtd < Minitest::Test
|
|
123
121
|
assert_equal("Warning: failed to load external entity \"test.dtd\" at :1.",
|
124
122
|
errors[0].to_s)
|
125
123
|
ensure
|
126
|
-
LibXML::XML.default_load_external_dtd = false
|
127
124
|
LibXML::XML::Error.reset_handler
|
128
125
|
end
|
129
126
|
end
|
data/test/test_encoding.rb
CHANGED
@@ -38,10 +38,7 @@ class TestEncoding < Minitest::Test
|
|
38
38
|
@encoding = encoding
|
39
39
|
file = file_for_encoding(encoding)
|
40
40
|
|
41
|
-
|
42
|
-
LibXML::XML.default_keep_blanks = false
|
43
|
-
@doc = LibXML::XML::Document.file(file)
|
44
|
-
LibXML::XML.default_keep_blanks = true
|
41
|
+
@doc = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NOBLANKS)
|
45
42
|
end
|
46
43
|
|
47
44
|
def test_encoding
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
# To make testing/debugging easier, test within this source tree versus an installed gem
|
4
|
-
|
5
4
|
require 'bundler/setup'
|
6
|
-
|
5
|
+
|
6
|
+
# Add ext directory to load path to make it easier to test locally built extensions
|
7
|
+
ext_path = File.expand_path(File.join(__dir__, '..', 'ext', 'libxml'))
|
8
|
+
$LOAD_PATH.unshift(File.expand_path(ext_path))
|
9
|
+
|
10
|
+
# Now load code
|
7
11
|
require 'libxml-ruby'
|
8
12
|
|
9
13
|
def windows?
|
@@ -11,3 +15,6 @@ def windows?
|
|
11
15
|
end
|
12
16
|
|
13
17
|
STDOUT.write "\nlibxml2: #{LibXML::XML::LIBXML_VERSION}\n#{RUBY_DESCRIPTION}\n\n"
|
18
|
+
|
19
|
+
require 'minitest/autorun'
|
20
|
+
|