Class: Moxml::Adapter::Base
- Inherits:
-
Object
- Object
- Moxml::Adapter::Base
show all
- Extended by:
- XmlUtils
- Defined in:
- lib/moxml/adapter/base.rb
Class Method Summary
collapse
-
.create_cdata(content) ⇒ Object
-
.create_comment(content) ⇒ Object
-
.create_declaration(version = "1.0", encoding = "UTF-8", standalone = nil) ⇒ Object
-
.create_doctype(name, external_id, system_id) ⇒ Object
-
.create_document(_native_doc = nil) ⇒ Object
-
.create_element(name) ⇒ Object
-
.create_namespace(element, prefix, uri) ⇒ Object
-
.create_processing_instruction(target, content) ⇒ Object
-
.create_text(content) ⇒ Object
-
.duplicate_node(node) ⇒ Object
-
.parse(_xml, _options = {}) ⇒ Object
-
.patch_node(node, _parent = nil) ⇒ Object
-
.prepare_for_new_document(node, _target_doc) ⇒ Object
-
.sax_parse(_xml, _handler) ⇒ void
Parse XML using SAX (event-driven) parsing.
-
.sax_supported? ⇒ Boolean
Check if this adapter supports SAX parsing.
-
.set_attribute_name(attribute, name) ⇒ Object
-
.set_attribute_value(attribute, value) ⇒ Object
-
.set_root(_doc, _element) ⇒ Object
Methods included from XmlUtils
encode_entities, normalize_xml_value, validate_comment_content, validate_declaration_encoding, validate_declaration_standalone, validate_declaration_version, validate_element_name, validate_pi_target, validate_prefix, validate_uri
Class Method Details
.create_cdata(content) ⇒ Object
74
75
76
|
# File 'lib/moxml/adapter/base.rb', line 74
def create_cdata(content)
create_native_cdata(normalize_xml_value(content))
end
|
78
79
80
81
|
# File 'lib/moxml/adapter/base.rb', line 78
def (content)
(content)
(normalize_xml_value(content))
end
|
.create_declaration(version = "1.0", encoding = "UTF-8", standalone = nil) ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/moxml/adapter/base.rb', line 93
def create_declaration(version = "1.0", encoding = "UTF-8",
standalone = nil)
validate_declaration_version(version)
validate_declaration_encoding(encoding)
validate_declaration_standalone(standalone)
create_native_declaration(version, encoding, standalone)
end
|
.create_doctype(name, external_id, system_id) ⇒ Object
83
84
85
|
# File 'lib/moxml/adapter/base.rb', line 83
def create_doctype(name, external_id, system_id)
create_native_doctype(name, external_id, system_id)
end
|
.create_document(_native_doc = nil) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/moxml/adapter/base.rb', line 56
def create_document(_native_doc = nil)
raise Moxml::NotImplementedError.new(
"create_document not implemented",
feature: "create_document",
adapter: name,
)
end
|
.create_element(name) ⇒ Object
64
65
66
67
|
# File 'lib/moxml/adapter/base.rb', line 64
def create_element(name)
validate_element_name(name)
create_native_element(name)
end
|
.create_namespace(element, prefix, uri) ⇒ Object
101
102
103
104
105
|
# File 'lib/moxml/adapter/base.rb', line 101
def create_namespace(element, prefix, uri)
validate_prefix(prefix) if prefix
validate_uri(uri)
create_native_namespace(element, prefix, uri)
end
|
.create_processing_instruction(target, content) ⇒ Object
87
88
89
90
91
|
# File 'lib/moxml/adapter/base.rb', line 87
def create_processing_instruction(target, content)
validate_pi_target(target)
create_native_processing_instruction(target,
normalize_xml_value(content))
end
|
.create_text(content) ⇒ Object
69
70
71
72
|
# File 'lib/moxml/adapter/base.rb', line 69
def create_text(content)
create_native_text(normalize_xml_value(content).dup)
end
|
.duplicate_node(node) ⇒ Object
115
116
117
|
# File 'lib/moxml/adapter/base.rb', line 115
def duplicate_node(node)
node.dup
end
|
.parse(_xml, _options = {}) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/moxml/adapter/base.rb', line 22
def parse(_xml, _options = {})
raise Moxml::NotImplementedError.new(
"parse not implemented",
feature: "parse",
adapter: name,
)
end
|
.patch_node(node, _parent = nil) ⇒ Object
119
120
121
122
|
# File 'lib/moxml/adapter/base.rb', line 119
def patch_node(node, _parent = nil)
node
end
|
.prepare_for_new_document(node, _target_doc) ⇒ Object
124
125
126
127
128
129
|
# File 'lib/moxml/adapter/base.rb', line 124
def prepare_for_new_document(node, _target_doc)
node
end
|
.sax_parse(_xml, _handler) ⇒ void
This method returns an undefined value.
Parse XML using SAX (event-driven) parsing
SAX parsing provides a memory-efficient way to process XML by triggering events as the document is parsed, rather than building a complete DOM tree.
40
41
42
43
44
45
46
|
# File 'lib/moxml/adapter/base.rb', line 40
def sax_parse(_xml, _handler)
raise Moxml::NotImplementedError.new(
"sax_parse not implemented",
feature: "sax_parse",
adapter: name,
)
end
|
.sax_supported? ⇒ Boolean
Check if this adapter supports SAX parsing
51
52
53
54
|
# File 'lib/moxml/adapter/base.rb', line 51
def sax_supported?
respond_to?(:sax_parse) &&
method(:sax_parse).owner != Moxml::Adapter::Base.singleton_class
end
|
.set_attribute_name(attribute, name) ⇒ Object
107
108
109
|
# File 'lib/moxml/adapter/base.rb', line 107
def set_attribute_name(attribute, name)
attribute.name = name
end
|
.set_attribute_value(attribute, value) ⇒ Object
111
112
113
|
# File 'lib/moxml/adapter/base.rb', line 111
def set_attribute_value(attribute, value)
attribute.value = value
end
|
.set_root(_doc, _element) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/moxml/adapter/base.rb', line 14
def set_root(_doc, _element)
raise Moxml::NotImplementedError.new(
"set_root not implemented",
feature: "set_root",
adapter: name,
)
end
|