Module: Taka::DOM::Document

Defined in:
lib/taka/dom/document.rb

Instance Method Summary collapse

Instance Method Details

#adoptNode(source) ⇒ Object

Raises:

  • (NotImplementedError)


124
125
126
# File 'lib/taka/dom/document.rb', line 124

def adoptNode(source)
  raise(NotImplementedError.new)
end

#attributesObject



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

Raises:

  • (NotImplementedError)


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

#createDocumentFragmentObject



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

Raises:

  • (NotImplementedError)


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

#doctypeObject



16
17
18
# File 'lib/taka/dom/document.rb', line 16

def doctype
  internal_subset
end

#documentElementObject



24
25
26
# File 'lib/taka/dom/document.rb', line 24

def documentElement
  root
end

#documentURIObject

Raises:

  • (NotImplementedError)


118
119
120
# File 'lib/taka/dom/document.rb', line 118

def documentURI
  raise(NotImplementedError.new)
end

#documentURI=(_) ⇒ Object

Raises:

  • (NotImplementedError)


121
122
123
# File 'lib/taka/dom/document.rb', line 121

def documentURI=(_)
  raise(NotImplementedError.new)
end

#domConfigObject

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


90
91
92
# File 'lib/taka/dom/document.rb', line 90

def getElementsByTagNameNS(namespaceURI, localName)
  raise(NotImplementedError.new)
end

#getImplementationObject



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

#implementationObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/taka/dom/document.rb', line 20

def implementation
  raise(NotImplementedError.new)
end

#importNode(importedNode, deep) ⇒ Object

Raises:

  • (NotImplementedError)


81
82
83
# File 'lib/taka/dom/document.rb', line 81

def importNode(importedNode, deep)
  raise(NotImplementedError.new)
end

#inputEncodingObject

Raises:

  • (NotImplementedError)


94
95
96
# File 'lib/taka/dom/document.rb', line 94

def inputEncoding
  raise(NotImplementedError.new)
end

#js_property?(name) ⇒ Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/taka/dom/document.rb', line 161

def js_property? name
  [:body].include?(name)
end

#normalizeDocumentObject

Raises:

  • (NotImplementedError)


130
131
132
# File 'lib/taka/dom/document.rb', line 130

def normalizeDocument
  raise(NotImplementedError.new)
end

#renameNode(n, namespaceURI, qualifiedName) ⇒ Object

Raises:

  • (NotImplementedError)


133
134
135
# File 'lib/taka/dom/document.rb', line 133

def renameNode(n, namespaceURI, qualifiedName)
  raise(NotImplementedError.new)
end

#strictErrorCheckingObject

Raises:

  • (NotImplementedError)


112
113
114
# File 'lib/taka/dom/document.rb', line 112

def strictErrorChecking
  raise(NotImplementedError.new)
end

#strictErrorChecking=(_) ⇒ Object

Raises:

  • (NotImplementedError)


115
116
117
# File 'lib/taka/dom/document.rb', line 115

def strictErrorChecking=(_)
  raise(NotImplementedError.new)
end

#xmlEncodingObject

Raises:

  • (NotImplementedError)


97
98
99
# File 'lib/taka/dom/document.rb', line 97

def xmlEncoding
  raise(NotImplementedError.new)
end

#xmlStandaloneObject

Raises:

  • (NotImplementedError)


100
101
102
# File 'lib/taka/dom/document.rb', line 100

def xmlStandalone
  raise(NotImplementedError.new)
end

#xmlStandalone=(_) ⇒ Object

Raises:

  • (NotImplementedError)


103
104
105
# File 'lib/taka/dom/document.rb', line 103

def xmlStandalone=(_)
  raise(NotImplementedError.new)
end

#xmlVersionObject

Raises:

  • (NotImplementedError)


106
107
108
# File 'lib/taka/dom/document.rb', line 106

def xmlVersion
  raise(NotImplementedError.new)
end

#xmlVersion=(_) ⇒ Object

Raises:

  • (NotImplementedError)


109
110
111
# File 'lib/taka/dom/document.rb', line 109

def xmlVersion=(_)
  raise(NotImplementedError.new)
end