class XML::DOM::Document

Class XML::DOM::Document

superclass

Node

Class XML::DOM::Document

superclass

Node

Constants

XMLNSNS

Public Class Methods

new(*children) click to toggle source

new([child1, child2, …]) or new(child1, child2, …)

child?: String or Node
Calls superclass method XML::DOM::Node::new
# File lib/xml/dom/core.rb, line 1517
def initialize(*children)
  super(*children)
end

Public Instance Methods

_checkNode(node) click to toggle source
# File lib/xml/dom/core.rb, line 1727
def _checkNode(node)
  unless node.nodeType == ELEMENT_NODE ||
      node.nodeType == PROCESSING_INSTRUCTION_NODE ||
      node.nodeType == COMMENT_NODE ||
      node.nodeType == DOCUMENT_TYPE_NODE
    raise DOMException.new(DOMException::HIERARCHY_REQUEST_ERR)
  end

  if node.nodeType == ELEMENT_NODE
    @children.each do |n|
      if n.nodeType == ELEMENT_NODE
        raise DOMException.new(DOMException::HIERARCHY_REQUEST_ERR)
      end
    end
  end

  if node.nodeType == DOCUMENT_TYPE_NODE
    @children.each do |n|
      if n.nodeType == DOCUMENT_TYPE_NODE
        raise DOMException.new(DOMException::HIERARCHY_REQUEST_ERR)
      end
    end
  end
end
_getIDAttrs() click to toggle source

get the ID list

experimental implement
# File lib/xml/dom/core.rb, line 1711
def _getIDAttrs
  return {'*'=>'id'} if @idattrs.nil?
  @idattrs
end
_getNamespaces(parentNamespaces = {}, all = false) click to toggle source
# File lib/xml/dom2/document.rb, line 310
def _getNamespaces(parentNamespaces = {}, all = false)
  { nil => nil }
end
_setIDAttr(attrname, elemname = '*') click to toggle source

set the ID list by the attribute name with the element name (or wildcard)

experimental implement
# File lib/xml/dom/core.rb, line 1704
def _setIDAttr(attrname, elemname = '*')
  @idattrs = {} if @idattrs.nil?
  @idattrs[elemname] = attrname
end
createAttribute(name) click to toggle source
# File lib/xml/dom/core.rb, line 1669
def createAttribute(name)
  ret = Attr.new(name)
  ret.ownerDocument = self
  ret
end
createAttributeNS(nsuri, qname) click to toggle source
DOM2
# File lib/xml/dom2/document.rb, line 257
def createAttributeNS(nsuri, qname)
  nsuri = XMLNSNS if qname == 'xmlns' or qname =~ /^xmlns:/u
  ret = Attr.new([nsuri, qname])
  ret.ownerDocument = self
  ret
end
createCDATASection(data) click to toggle source
# File lib/xml/dom/core.rb, line 1630
def createCDATASection(data)
  ret = CDATASection.new(data)
  ret.ownerDocument = self
  ret
end
createComment(data) click to toggle source
# File lib/xml/dom/core.rb, line 1643
def createComment(data)
  ret = Comment.new(data)
  ret.ownerDocument = self
  ret
end
createDocumentFragment() click to toggle source
# File lib/xml/dom/core.rb, line 1695
def createDocumentFragment
  ret = DocumentFragment.new
  ret.ownerDocument = self
  ret
end
createElement(tagName) click to toggle source
# File lib/xml/dom/core.rb, line 1604
def createElement(tagName)
  ret = Element.new(tagName)
  ret.ownerDocument = self
  ret
end
createElementNS(nsuri, qname) click to toggle source
# File lib/xml/dom2/document.rb, line 249
def createElementNS(nsuri, qname)
  ret = Element.new([nsuri, qname])
  ret.ownerDocument = self
  ret
end
createEntityReference(name) click to toggle source
# File lib/xml/dom/core.rb, line 1682
def createEntityReference(name)
  ret = EntityReference.new(name)
  ret.ownerDocument = self
  ret
end
createProcessingInstruction(target, data) click to toggle source
# File lib/xml/dom/core.rb, line 1656
def createProcessingInstruction(target, data)
  ret = ProcessingInstruction.new(target, data)
  ret.ownerDocument = self
  ret
end
createTextNode(data) click to toggle source
# File lib/xml/dom/core.rb, line 1617
def createTextNode(data)
  ret = Text.new(data)
  ret.ownerDocument = self
  ret
end
doctype() click to toggle source
# File lib/xml/dom/core.rb, line 1568
def doctype
  @children.each do |child|
    if child.nodeType == DOCUMENT_TYPE_NODE
      return child
    end
  end if @children
  nil
end
documentElement() click to toggle source
# File lib/xml/dom/core.rb, line 1552
def documentElement
  @children.each do |child|
    if child.nodeType == ELEMENT_NODE
      return child
    end
  end if @children
  nil
end
getElementById(elementId) click to toggle source
DOM2
# File lib/xml/dom2/document.rb, line 280
def getElementById(elementId)
  ## [NOT IMPLEMENTED]
  raise "not implemented"
end
getElementsByTagName(tagname) click to toggle source
# File lib/xml/dom/core.rb, line 1584
def getElementsByTagName(tagname)
  ret = NodeList.new
  @children.each do |node|
    if node.nodeType == ELEMENT_NODE
      if tagname == '*' || node.nodeName == tagname
        ret << node
      end
      ret << node.getElementsByTagName(tagname)
    end
  end if @children
  ret
end
getElementsByTagNameNS(nsuri, localname) click to toggle source
DOM2
# File lib/xml/dom2/document.rb, line 265
def getElementsByTagNameNS(nsuri, localname)
  ret = NodeList.new
  @children.each do |node|
    if node.nodeType == ELEMENT_NODE
      if (localname == '*' || node.localname == localname) and
          (nsuri == '*' || node.namespaceURI == nsuri)
        ret << node
      end
      ret << node.getElementsByTagNameNS(nsuri, localname)
    end
  end if @children
  ret
end
implementation() click to toggle source
DOM
# File lib/xml/dom/core.rb, line 1717
def implementation
  return @implemantation if @implemantation
  ## singleton
  @implemantation = DOMImplementation.instance
end
implementation=(impl) click to toggle source
# File lib/xml/dom/core.rb, line 1723
def implementation=(impl)
  @implemantation = impl
end
importNode(impnode, deep) click to toggle source
DOM2
# File lib/xml/dom2/document.rb, line 237
def importNode(impnode, deep)
  ## [NOT IMPLEMENTED]
  raise "not implemented"
end
nodeName() click to toggle source
# File lib/xml/dom/core.rb, line 1541
def nodeName
  "#document"
end
nodeType() click to toggle source

Methods

# File lib/xml/dom/core.rb, line 1530
def nodeType
  DOCUMENT_NODE
end