Class: VCDOM::MiniDOM::Document

Inherits:
Node
  • Object
show all
Includes:
ModElementsGetter, ModParentNode
Defined in:
lib/vcdom/minidom/document.rb

Constant Summary

Constants inherited from Node

Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::ENTITY_NODE, Node::ENTITY_REFERENCE_NODE, Node::NOTATION_NODE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE

Instance Method Summary collapse

Methods included from ModElementsGetter

#get_elements_by_tagname, #get_elements_by_tagname_ns

Methods included from ModParentNode

#child_nodes, #first_child, #has_child_nodes, #insert_before, #last_child, #replace_child

Methods inherited from Node

#attributes, #child_nodes, #first_child, #has_attributes, #has_child_nodes, #insert_before, #last_child, #local_name, #namespace_uri, #next_sibling, #node_value, #node_value=, #owner_document, #parent_node, #prefix, #prefix=, #previous_sibling, #replace_child

Constructor Details

#initializeDocument

def initialize( aDOMImplementation, aNamespaceURI, aQualifiedName, aDoctype )



207
208
209
210
211
212
# File 'lib/vcdom/minidom/document.rb', line 207

def initialize()
  super(nil)
  init_mod_parent_node()
  @doctype = nil
  @document_element = nil
end

Instance Method Details

#append_child(new_child) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/vcdom/minidom/document.rb', line 34

def append_child( new_child )
  super( new_child )
  case new_child.node_type
    when Node::ELEMENT_NODE then
      @document_element = new_child
    when Node::DOCUMENT_TYPE_NODE then
      @doctype = new_child
  end
end

#create_attribute(name) ⇒ Object

createAttribute

Creates an Attr of the given name. Note that the Attr instance can then be set on an Element 
using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.

Parameters
  name of type DOMString
    The name of the attribute.
Return Value
  Attr
    A new Attr object with the nodeName attribute set to name, and localName, prefix, 
    and namespaceURI set to null. The value of the attribute is the empty string.
Exceptions
  DOMException
    INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name 
              according to the XML version in use specified in the Document.xmlVersion attribute.


110
111
112
# File 'lib/vcdom/minidom/document.rb', line 110

def create_attribute( name )
  return Attr.new( self, name )
end

#create_attribute_ns(namespace_uri, qualified_name) ⇒ Object

createAttributeNS introduced in DOM Level 2

Creates an attribute of the given qualified name and namespace URI.
Per [XML Namespaces], applications must use the value null as the namespaceURI parameter 
for methods if they wish to have no namespace.

Parameters
  namespaceURI of type DOMString
    The namespace URI of the attribute to create.
  qualifiedName of type DOMString
    The qualified name of the attribute to instantiate.
Return Value
  Attr
    A new Attr object with the following attributes:
      Attribute         Value
      ---------------------------------------------------------------
      Node.nodeName     qualifiedName
      Node.namespaceURI namespaceURI
      Node.prefix       prefix, extracted from qualifiedName, or null if there is no prefix
      Node.localName    local name, extracted from qualifiedName
      Attr.name         qualifiedName
      Node.nodeValue    the empty string
Exceptions
  DOMException
    INVALID_CHARACTER_ERR: Raised if the specified qualifiedName is not an XML name according 
              to the XML version in use specified in the Document.xmlVersion attribute.
    NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, 
              if the qualifiedName has a prefix and the namespaceURI is null, 
              if the qualifiedName has a prefix that is "xml" and the namespaceURI is different 
              from "http://www.w3.org/XML/1998/namespace", if the qualifiedName or its prefix is 
              "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", 
              or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and 
              neither the qualifiedName nor its prefix is "xmlns".
      #=> QName が奇形の場合, QName が接頭辞を持ちながら名前空間 URI が null の場合, QName の接頭辞が
      #=> "xml" なのに名前空間 URI が "http://www.w3.org/XML/1998/namespace" ではない場合,
      #=> QName の接頭辞が "xmlns" にもかかわらず名前空間 URI が "http://www.w3.org/2000/xmlns/"
      #=> ではないとき, そして名前空間 URI が "http://www.w3.org/2000/xmlns/" なのに, QName または接頭辞が
      #=> "xmlns" ではないとき例外発生.
    NOT_SUPPORTED_ERR: Always thrown if the current document does not support the "XML" feature, 
              since namespaces were defined by XML.


154
155
156
# File 'lib/vcdom/minidom/document.rb', line 154

def create_attribute_ns( namespace_uri, qualified_name )
  return AttrNS.new( self, namespace_uri, qualified_name )
end

#create_cdata_section(data) ⇒ Object

createCDATASection

Creates a CDATASection node whose value is the specified string.

Parameters
  data of type DOMString
    The data for the CDATASection contents.
Return Value
  CDATASection
    The new CDATASection object.
Exceptions
  DOMException
    NOT_SUPPORTED_ERR: Raised if this document is an HTML document.


185
186
187
# File 'lib/vcdom/minidom/document.rb', line 185

def create_cdata_section( data )
  return CDATASection.new( self, data )
end

#create_comment(data) ⇒ Object

createComment

Creates a Comment node given the specified string.

Parameters
  data of type DOMString
    The data for the node.
Return Value
  Comment
    The new Comment object.
No Exceptions


200
201
202
# File 'lib/vcdom/minidom/document.rb', line 200

def create_comment( data )
  return Comment.new( self, data )
end

#create_element(tagname) ⇒ Object



53
54
55
# File 'lib/vcdom/minidom/document.rb', line 53

def create_element( tagname )
  return Element.new( self, tagname )
end

#create_element_ns(namespace_uri, qualified_name) ⇒ Object

createElementNS introduced in DOM Level 2

Creates an element of the given qualified name and namespace URI.
Per [XML Namespaces], applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

Parameters
  namespaceURI of type DOMString :  The namespace URI of the element to create.
  qualifiedName of type DOMString : The qualified name of the element type to instantiate.
Return Value
  Element :
    A new Element object with the following attributes:
      Attribute         Value
      ----------------------------------------
      Node.nodeName     qualifiedName
      Node.namespaceURI namespaceURI
      Node.prefix       prefix, extracted from qualifiedName, or null if there is no prefix
      Node.localName    local name, extracted from qualifiedName
      Element.tagName   qualifiedName
Exceptions
  DOMException
    INVALID_CHARACTER_ERR: Raised if the specified qualifiedName is not an 
              XML name according to the XML version in use specified in 
              the Document.xmlVersion attribute.
    NAMESPACE_ERR: Raised if the qualifiedName is a malformed qualified name, 
              if the qualifiedName has a prefix and the namespaceURI is null, 
              or if the qualifiedName has a prefix that is "xml" and the 
              namespaceURI is different from 
              "http://www.w3.org/XML/1998/namespace" [XML Namespaces], or 
              if the qualifiedName or its prefix is "xmlns" and the 
              namespaceURI is different from "http://www.w3.org/2000/xmlns/", 
              or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and 
              neither the qualifiedName nor its prefix is "xmlns".
    NOT_SUPPORTED_ERR: Always thrown if the current document does not support 
              the "XML" feature, since namespaces were defined by XML.


90
91
92
# File 'lib/vcdom/minidom/document.rb', line 90

def create_element_ns( namespace_uri, qualified_name )
  return ElementNS.new( self, namespace_uri, qualified_name )
end

#create_text_node(data) ⇒ Object

createTextNode

Creates a Text node given the specified string.

Parameters
  data of type DOMString
    The data for the node.
Return Value
  Text
    The new Text object.
No Exceptions


168
169
170
# File 'lib/vcdom/minidom/document.rb', line 168

def create_text_node( data )
  return Text.new( self, data )
end

#document_elementObject

documentElement of type Element, readonly

This is a convenience attribute that allows direct access to the child node 
that is the document element of the document.


32
# File 'lib/vcdom/minidom/document.rb', line 32

def document_element; return @document_element end

#implementationObject



27
# File 'lib/vcdom/minidom/document.rb', line 27

def implementation; return DOMImplementation.get_instance() end

#node_nameObject



24
# File 'lib/vcdom/minidom/document.rb', line 24

def node_name; return "#document" end

#node_typeObject

include Const



23
# File 'lib/vcdom/minidom/document.rb', line 23

def node_type; return Node::DOCUMENT_NODE end

#remove_child(old_child) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/vcdom/minidom/document.rb', line 43

def remove_child( old_child )
  super( old_child )
  case old_child.node_type
    when Node::ELEMENT_NODE then
      @document_element = nil
    when Node::DOCUMENT_TYPE_NODE then
      @doctype = nil
  end
end

#text_contentObject



25
# File 'lib/vcdom/minidom/document.rb', line 25

def text_content; return nil end

#text_content=(value) ⇒ Object



26
# File 'lib/vcdom/minidom/document.rb', line 26

def text_content=( value );  end