oga 2.6-java → 2.7-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/c/lexer.c +1020 -957
- data/ext/java/org/liboga/xml/Lexer.java +241 -235
- data/ext/ragel/base_lexer.rl +1 -1
- data/lib/liboga.jar +0 -0
- data/lib/oga.rb +1 -1
- data/lib/oga/version.rb +1 -1
- data/lib/oga/xml/element.rb +5 -5
- data/lib/oga/xml/generator.rb +18 -4
- data/lib/oga/xml/xml_declaration.rb +4 -3
- metadata +2 -2
data/ext/ragel/base_lexer.rl
CHANGED
data/lib/liboga.jar
CHANGED
Binary file
|
data/lib/oga.rb
CHANGED
@@ -35,8 +35,8 @@ require 'oga/xml/character_node'
|
|
35
35
|
require 'oga/xml/text'
|
36
36
|
require 'oga/xml/comment'
|
37
37
|
require 'oga/xml/cdata'
|
38
|
-
require 'oga/xml/xml_declaration'
|
39
38
|
require 'oga/xml/processing_instruction'
|
39
|
+
require 'oga/xml/xml_declaration'
|
40
40
|
require 'oga/xml/doctype'
|
41
41
|
require 'oga/xml/namespace'
|
42
42
|
require 'oga/xml/default_namespace'
|
data/lib/oga/version.rb
CHANGED
data/lib/oga/xml/element.rb
CHANGED
@@ -91,6 +91,8 @@ module Oga
|
|
91
91
|
found ? found.value : nil
|
92
92
|
end
|
93
93
|
|
94
|
+
alias_method :[], :get
|
95
|
+
|
94
96
|
# Adds a new attribute to the element.
|
95
97
|
#
|
96
98
|
# @param [Oga::XML::Attribute] attribute
|
@@ -113,11 +115,7 @@ module Oga
|
|
113
115
|
if found
|
114
116
|
found.value = value
|
115
117
|
else
|
116
|
-
|
117
|
-
ns, name = name.split(':')
|
118
|
-
else
|
119
|
-
ns = nil
|
120
|
-
end
|
118
|
+
name, ns = split_name(name)
|
121
119
|
|
122
120
|
attr = Attribute.new(
|
123
121
|
:name => name,
|
@@ -129,6 +127,8 @@ module Oga
|
|
129
127
|
end
|
130
128
|
end
|
131
129
|
|
130
|
+
alias_method :[]=, :set
|
131
|
+
|
132
132
|
# Removes an attribute from the element.
|
133
133
|
#
|
134
134
|
# @param [String] name The name (optionally including namespace prefix)
|
data/lib/oga/xml/generator.rb
CHANGED
@@ -17,8 +17,8 @@ module Oga
|
|
17
17
|
def initialize(root)
|
18
18
|
@start = root
|
19
19
|
|
20
|
-
if @start.respond_to?(:
|
21
|
-
@html_mode = @start.
|
20
|
+
if @start.respond_to?(:html?)
|
21
|
+
@html_mode = @start.html?
|
22
22
|
else
|
23
23
|
@html_mode = false
|
24
24
|
end
|
@@ -48,12 +48,14 @@ module Oga
|
|
48
48
|
callback = :on_comment
|
49
49
|
when Oga::XML::Attribute
|
50
50
|
callback = :on_attribute
|
51
|
+
when Oga::XML::XmlDeclaration
|
52
|
+
# This must come before ProcessingInstruction since XmlDeclaration
|
53
|
+
# extends ProcessingInstruction.
|
54
|
+
callback = :on_xml_declaration
|
51
55
|
when Oga::XML::ProcessingInstruction
|
52
56
|
callback = :on_processing_instruction
|
53
57
|
when Oga::XML::Doctype
|
54
58
|
callback = :on_doctype
|
55
|
-
when Oga::XML::XmlDeclaration
|
56
|
-
callback = :on_xml_declaration
|
57
59
|
when Oga::XML::Document
|
58
60
|
callback = :on_document
|
59
61
|
children = true
|
@@ -73,6 +75,10 @@ module Oga
|
|
73
75
|
|
74
76
|
break
|
75
77
|
else
|
78
|
+
# Make sure to always close the current element before
|
79
|
+
# moving to any siblings.
|
80
|
+
after_element(current, output) if current.is_a?(Element)
|
81
|
+
|
76
82
|
until next_node = current.is_a?(Node) && current.next
|
77
83
|
if current.is_a?(Node) && current != @start
|
78
84
|
current = current.parent
|
@@ -175,6 +181,14 @@ module Oga
|
|
175
181
|
on_doctype(doc.doctype, output)
|
176
182
|
output << "\n"
|
177
183
|
end
|
184
|
+
|
185
|
+
first_child = doc.children[0]
|
186
|
+
|
187
|
+
# Prevent excessive newlines in case the next node is a newline text
|
188
|
+
# node.
|
189
|
+
if first_child.is_a?(Text) && first_child.text.start_with?("\r\n", "\n")
|
190
|
+
output.chomp!
|
191
|
+
end
|
178
192
|
end
|
179
193
|
|
180
194
|
# @param [Oga::XML::XmlDeclaration] node
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module Oga
|
2
2
|
module XML
|
3
3
|
# Class containing information about an XML declaration tag.
|
4
|
-
class XmlDeclaration
|
5
|
-
include ToXML
|
6
|
-
|
4
|
+
class XmlDeclaration < ProcessingInstruction
|
7
5
|
# @return [String]
|
8
6
|
attr_accessor :version
|
9
7
|
|
@@ -20,9 +18,12 @@ module Oga
|
|
20
18
|
# @option options [String] :encoding
|
21
19
|
# @option options [String] :standalone
|
22
20
|
def initialize(options = {})
|
21
|
+
super
|
22
|
+
|
23
23
|
@version = options[:version] || '1.0'
|
24
24
|
@encoding = options[:encoding] || 'UTF-8'
|
25
25
|
@standalone = options[:standalone]
|
26
|
+
@name = 'xml'
|
26
27
|
end
|
27
28
|
|
28
29
|
# @return [String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.7'
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Yorick Peterse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|