Module: Taka::DOM::Document
- Defined in:
- lib/taka/dom/document.rb
Instance Method Summary collapse
- #adoptNode(source) ⇒ Object
- #attributes ⇒ Object
- #createAttribute(name) ⇒ Object
- #createAttributeNS(namespaceURI, qualifiedName) ⇒ Object
- #createCDATASection(data) ⇒ Object
- #createComment(data) ⇒ Object
- #createDocumentFragment ⇒ Object
- #createElement(tag_name) ⇒ Object
- #createElementNS(namespaceURI, qualifiedName) ⇒ Object
- #createEntityReference(name) ⇒ Object
- #createProcessingInstruction(target, data) ⇒ Object
- #createTextNode(data) ⇒ Object
- #decorate(node) ⇒ Object
- #doctype ⇒ Object
- #documentElement ⇒ Object
- #documentURI ⇒ Object
- #documentURI=(_) ⇒ Object
- #domConfig ⇒ Object
- #getElementById(id_name) ⇒ Object
- #getElementsByTagName(name) ⇒ Object
- #getElementsByTagNameNS(namespaceURI, localName) ⇒ Object
- #getImplementation ⇒ Object
- #hasFeature(type, version) ⇒ Object
- #implementation ⇒ Object
- #importNode(importedNode, deep) ⇒ Object
- #inputEncoding ⇒ Object
- #js_property?(name) ⇒ Boolean
- #normalizeDocument ⇒ Object
- #renameNode(n, namespaceURI, qualifiedName) ⇒ Object
- #strictErrorChecking ⇒ Object
- #strictErrorChecking=(_) ⇒ Object
- #xmlEncoding ⇒ Object
- #xmlStandalone ⇒ Object
- #xmlStandalone=(_) ⇒ Object
- #xmlVersion ⇒ Object
- #xmlVersion=(_) ⇒ Object
Instance Method Details
#adoptNode(source) ⇒ Object
124 125 126 |
# File 'lib/taka/dom/document.rb', line 124 def adoptNode(source) raise(NotImplementedError.new) end |
#attributes ⇒ Object
28 29 30 |
# File 'lib/taka/dom/document.rb', line 28 def attributes nil end |
#createAttribute(name) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/taka/dom/document.rb', line 59 def createAttribute name unless name =~ /^\w+$/ raise DOMException.new(DOMException::INVALID_CHARACTER_ERR) end Nokogiri::XML::Attr.new(self, name) end |
#createAttributeNS(namespaceURI, qualifiedName) ⇒ Object
87 88 89 |
# File 'lib/taka/dom/document.rb', line 87 def createAttributeNS(namespaceURI, qualifiedName) raise(NotImplementedError.new) end |
#createCDATASection(data) ⇒ Object
51 52 53 |
# File 'lib/taka/dom/document.rb', line 51 def createCDATASection(data) Nokogiri::XML::CDATA.new(self, data) end |
#createComment(data) ⇒ Object
47 48 49 |
# File 'lib/taka/dom/document.rb', line 47 def createComment(data) Nokogiri::XML::Comment.new(self, data) end |
#createDocumentFragment ⇒ Object
39 40 41 |
# File 'lib/taka/dom/document.rb', line 39 def createDocumentFragment Nokogiri::XML::DocumentFragment.new(self) end |
#createElement(tag_name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/taka/dom/document.rb', line 32 def createElement tag_name unless tag_name =~ /^\w+$/ raise Taka::DOMException.new(Taka::DOMException::INVALID_CHARACTER_ERR) end Nokogiri::XML::Node.new(tag_name, self) end |
#createElementNS(namespaceURI, qualifiedName) ⇒ Object
84 85 86 |
# File 'lib/taka/dom/document.rb', line 84 def createElementNS(namespaceURI, qualifiedName) raise(NotImplementedError.new) end |
#createEntityReference(name) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/taka/dom/document.rb', line 66 def createEntityReference name unless name =~ /^\w+$/ raise DOMException.new(DOMException::INVALID_CHARACTER_ERR) end Nokogiri::XML::EntityReference.new(self, name) end |
#createProcessingInstruction(target, data) ⇒ Object
55 56 57 |
# File 'lib/taka/dom/document.rb', line 55 def createProcessingInstruction(target, data) Nokogiri::XML::ProcessingInstruction.new(self, target, data) end |
#createTextNode(data) ⇒ Object
43 44 45 |
# File 'lib/taka/dom/document.rb', line 43 def createTextNode data Nokogiri::XML::Text.new(data, self) end |
#decorate(node) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/taka/dom/document.rb', line 137 def decorate node nx = Nokogiri::XML list = { nx::Node => [DOM::Element, DOM::Node], nx::Element => [DOM::Element, DOM::Node], nx::Attr => [DOM::Element, DOM::Node, DOM::Attr], nx::NodeSet => [DOM::NodeSet], nx::Text => [DOM::Element, DOM::Node, DOM::CharacterData, DOM::Text], nx::CDATA => [DOM::Element, DOM::Node, DOM::Text, DOM::CharacterData], nx::ProcessingInstruction => [DOM::Element, DOM::Node, DOM::ProcessingInstruction], nx::EntityDeclaration => [DOM::Element, DOM::Node, DOM::EntityDeclaration], nx::EntityReference => [DOM::Element, DOM::Node, DOM::EntityReference], nx::DTD => [DOM::Element, DOM::Node, DOM::DTD], nx::DocumentFragment => [DOM::Element, DOM::Node, DOM::DocumentFragment], nx::Comment => [DOM::Element, DOM::Node, DOM::Comment], nx::Notation => [DOM::Element, DOM::Node, DOM::Notation], }[node.class] raise("Unknown type #{node.class.name}") unless list list.each { |mod| node.extend(mod) } node end |
#doctype ⇒ Object
16 17 18 |
# File 'lib/taka/dom/document.rb', line 16 def doctype internal_subset end |
#documentElement ⇒ Object
24 25 26 |
# File 'lib/taka/dom/document.rb', line 24 def documentElement root end |
#documentURI ⇒ Object
118 119 120 |
# File 'lib/taka/dom/document.rb', line 118 def documentURI raise(NotImplementedError.new) end |
#documentURI=(_) ⇒ Object
121 122 123 |
# File 'lib/taka/dom/document.rb', line 121 def documentURI=(_) raise(NotImplementedError.new) end |
#domConfig ⇒ Object
127 128 129 |
# File 'lib/taka/dom/document.rb', line 127 def domConfig raise(NotImplementedError.new) end |
#getElementById(id_name) ⇒ Object
12 13 14 |
# File 'lib/taka/dom/document.rb', line 12 def getElementById id_name css("##{id_name}").first end |
#getElementsByTagName(name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/taka/dom/document.rb', line 4 def getElementsByTagName name prefix = namespaces.keys.first path = prefix ? "#{prefix}:#{name}" : name DOM::NodeList.new do xpath("//#{path}", namespaces) end end |
#getElementsByTagNameNS(namespaceURI, localName) ⇒ Object
90 91 92 |
# File 'lib/taka/dom/document.rb', line 90 def getElementsByTagNameNS(namespaceURI, localName) raise(NotImplementedError.new) end |
#getImplementation ⇒ Object
73 74 75 |
# File 'lib/taka/dom/document.rb', line 73 def getImplementation self end |
#hasFeature(type, version) ⇒ Object
77 78 79 |
# File 'lib/taka/dom/document.rb', line 77 def hasFeature type, version return true if type.downcase == 'xml' end |
#implementation ⇒ Object
20 21 22 |
# File 'lib/taka/dom/document.rb', line 20 def implementation raise(NotImplementedError.new) end |
#importNode(importedNode, deep) ⇒ Object
81 82 83 |
# File 'lib/taka/dom/document.rb', line 81 def importNode(importedNode, deep) raise(NotImplementedError.new) end |
#inputEncoding ⇒ Object
94 95 96 |
# File 'lib/taka/dom/document.rb', line 94 def inputEncoding raise(NotImplementedError.new) end |
#js_property?(name) ⇒ Boolean
161 162 163 |
# File 'lib/taka/dom/document.rb', line 161 def js_property? name [:body].include?(name) end |
#normalizeDocument ⇒ Object
130 131 132 |
# File 'lib/taka/dom/document.rb', line 130 def normalizeDocument raise(NotImplementedError.new) end |
#renameNode(n, namespaceURI, qualifiedName) ⇒ Object
133 134 135 |
# File 'lib/taka/dom/document.rb', line 133 def renameNode(n, namespaceURI, qualifiedName) raise(NotImplementedError.new) end |
#strictErrorChecking ⇒ Object
112 113 114 |
# File 'lib/taka/dom/document.rb', line 112 def strictErrorChecking raise(NotImplementedError.new) end |
#strictErrorChecking=(_) ⇒ Object
115 116 117 |
# File 'lib/taka/dom/document.rb', line 115 def strictErrorChecking=(_) raise(NotImplementedError.new) end |
#xmlEncoding ⇒ Object
97 98 99 |
# File 'lib/taka/dom/document.rb', line 97 def xmlEncoding raise(NotImplementedError.new) end |
#xmlStandalone ⇒ Object
100 101 102 |
# File 'lib/taka/dom/document.rb', line 100 def xmlStandalone raise(NotImplementedError.new) end |
#xmlStandalone=(_) ⇒ Object
103 104 105 |
# File 'lib/taka/dom/document.rb', line 103 def xmlStandalone=(_) raise(NotImplementedError.new) end |
#xmlVersion ⇒ Object
106 107 108 |
# File 'lib/taka/dom/document.rb', line 106 def xmlVersion raise(NotImplementedError.new) end |
#xmlVersion=(_) ⇒ Object
109 110 111 |
# File 'lib/taka/dom/document.rb', line 109 def xmlVersion=(_) raise(NotImplementedError.new) end |