Class: XML::DOM::DocumentType

Inherits:
Node
  • Object
show all
Defined in:
lib/xml/dom/core.rb,
lib/xml/dom2/documenttype.rb

Overview

Class XML::DOM::DocumentType

superclass

Node

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::NODE_NODE, Node::NOTATION_NODE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE

Instance Method Summary collapse

Methods inherited from Node

#+, #<=>, #==, #[], #[]=, #__collectAncestorNS, #__collectDescendatNS, #__sibling, #_ancestor, #_checkNode, #_child, #_descendant, #_following, #_fsibling, #_getChildIndex, #_getMyLocation, #_getMyLocationInXPath, #_getNodeByAbsoluteLocationTerm, #_insertNodes, #_matchAttribute?, #_matchNode?, #_matchNodeAttributes?, #_matchNodeType?, #_nodesByLocationTerms, #_nodesByRelativeLocationTerm, #_preceding, #_psibling, #_removeFromTree, #_removeNode, #_searchID, #accept, #accept_name, #appendChild, #attributes, #childNodes, #childNodes=, #children_accept, #children_accept_name, #each, #firstChild, #getDigest, #getNodesByXPath, #getNodesByXPointer, #hasAttributes, #hasChildNodes, #insertBefore, #inspect, #isSupported, #lastChild, #localname, #makeXPath, #makeXPointer, #namespaceURI, #nextSibling, #nodeValue, #nodeValue=, #ownerDocument, #ownerDocument=, #parentNode, #parentNode=, #prefix, #prefix=, #previousSibling, #removeChild, #replaceChild, #trim

Constructor Details

#initialize(name, pubid, sysid, *children) ⇒ DocumentType

Class Methods

--- DocumentType.new(name, pubid, sysid, *children)

creates a new DocuemntType.



2748
2749
2750
2751
2752
2753
# File 'lib/xml/dom/core.rb', line 2748

def initialize(name, value = nil, *children)
  super(*children)
  raise "parameter error" if !name
  @name = name.freeze
  @value = value.freeze
end

Instance Method Details

#cloneNode(deep = true) ⇒ Object

DOM


2832
2833
2834
# File 'lib/xml/dom/core.rb', line 2832

def cloneNode(deep = true)
  super(deep, @name, @value)
end

#dump(depth = 0) ⇒ Object

— DocumentType#dump(depth = 0)

dumps the DocumentType.



2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
# File 'lib/xml/dom/core.rb', line 2809

def dump(depth = 0)
  print ' ' * depth * 2
  print "<!DOCTYPE #{@name} #{@value} [\n"
  @children.each do |child|
    print ' ' * (depth + 1) * 2
    if child.nodeType == PROCESSING_INSTRUCTION_NODE ||
        child.nodeType == COMMENT_NODE
      child.dump
    else
      print child.nodeValue, "\n"
    end
  end if @children
  print ' ' * depth * 2
  print "]>\n"
end

#internalSubsetObject

DOM2


99
# File 'lib/xml/dom2/documenttype.rb', line 99

def internalSubset; end

#nodeNameObject

DOM


2775
2776
2777
# File 'lib/xml/dom/core.rb', line 2775

def nodeName
  @name
end

#nodeTypeObject

DOM


2764
2765
2766
# File 'lib/xml/dom/core.rb', line 2764

def nodeType
  DOCUMENT_TYPE_NODE
end

#publicIdObject

DOM2


93
# File 'lib/xml/dom2/documenttype.rb', line 93

def publicId; @pubid; end

#systemIdObject

DOM2


96
# File 'lib/xml/dom2/documenttype.rb', line 96

def systemId; @sysid; end

#to_sObject

— DocumentType#to_s

returns the string representation of the DocumentType.



2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
# File 'lib/xml/dom/core.rb', line 2784

def to_s
  ret = "<!DOCTYPE " + @name
  if !@value.nil?
    ret <<= " " + @value
  end
  if !@children.nil? && @children.length > 0
    ret <<= " [\n"
    @children.each do |child|
      if child.nodeType == PROCESSING_INSTRUCTION_NODE ||
          child.nodeType == COMMENT_NODE
        ret <<= child.to_s + "\n"
      else
        ret <<= child.nodeValue + "\n"
      end
    end
    ret <<= "]"
  end
  ret <<= ">"
end