Class: XML::DOM::CDATASection

Inherits:
Text show all
Defined in:
lib/xml/dom/core.rb,
lib/xml/dom2/xpath.rb,
lib/xml/dom2/cdatasection.rb

Overview

Class XML::DOM::CDATASection

superclass

Text

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 Text

#getDigest, #splitText, #trim

Methods inherited from CharacterData

#appendData, #cloneNode, #data, #data=, #deleteData, #insertData, #length, #nodeValue, #nodeValue=, #replaceData, #substringData

Methods inherited from Node

#+, #<=>, #==, #[], #[]=, #__collectAncestorNS, #__collectDescendatNS, #__sibling, #_ancestor, #_checkNode, #_child, #_descendant, #_following, #_fsibling, #_getChildIndex, #_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, #cloneNode, #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(text = nil) ⇒ CDATASection

Class Methods

--- CDATASection.new(text = nil)

creates a new CDATASection.



2671
2672
2673
2674
# File 'lib/xml/dom/core.rb', line 2671

def initialize(text = nil)
  super(text)
  raise "parameter error" if !text
end

Instance Method Details

#_getMyLocation(parent) ⇒ Object



2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
# File 'lib/xml/dom/core.rb', line 2719

def _getMyLocation(parent)
  index = 1
  parent.childNodes do |child|
    if child == self
      return "child(#{index},#cdata)"
    end
    if child.nodeType == CDATA_SECTION_NODE
      index += 1
    end
  end
  nil
end

#_getMyLocationInXPath(parent) ⇒ Object



352
353
354
355
356
357
# File 'lib/xml/dom2/xpath.rb', line 352

def _getMyLocationInXPath(parent)
  n = parent.childNodes.to_a.select { |i|
    i.nodeType == TEXT_NODE or i.nodeType == CDATA_SECTION_NODE
  }.index(self)
  "text()[#{n + 1}]"
end

#dump(depth = 0) ⇒ Object

— CDATASection#dump(depth = 0)

dumps the CDATASection.



2714
2715
2716
2717
# File 'lib/xml/dom/core.rb', line 2714

def dump(depth = 0)
  print ' ' * depth * 2
  print "<![CDATA[#{@value.inspect}]]>\n"
end

#nodeNameObject

DOM


2696
2697
2698
# File 'lib/xml/dom/core.rb', line 2696

def nodeName
  "#cdata-section"
end

#nodeTypeObject

DOM


2685
2686
2687
# File 'lib/xml/dom/core.rb', line 2685

def nodeType
  CDATA_SECTION_NODE
end

#to_sObject

— CDATASection#to_s

returns the string representation of the CDATASection.



2705
2706
2707
# File 'lib/xml/dom/core.rb', line 2705

def to_s
  "<![CDATA[#{@value}]]>"
end