Class: VCDOM::MiniDOM::Attr

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

Direct Known Subclasses

AttrNS

Defined Under Namespace

Modules: OwnerElementManageable

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 ModParentNode

#append_child, #child_nodes, #first_child, #has_child_nodes, #insert_before, #last_child, #remove_child, #replace_child, #text_content, #text_content=

Methods inherited from Node

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

Constructor Details

#initialize(owner_document, name) ⇒ Attr

コンストラクタ =====
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
113
114
115
116
117
118
119
# File 'lib/vcdom/minidom/attr.rb', line 110

def initialize( owner_document, name )
  if XMLRegExp::NAME !~ name then
    # the specified qualified name is not an XML name
    raise DOMException.new( DOMException::INVALID_CHARACTER_ERR, 
            'The specified name "' + name + '" is not an XML name.' )
  end
  super( owner_document )
  init_mod_parent_node()
  @name = name
end

Instance Method Details

#nameObject Also known as: node_name

name of type DOMString, readonly

Returns the name of this attribute. 
If Node.localName is different from null, this attribute is a qualified name.


29
30
31
# File 'lib/vcdom/minidom/attr.rb', line 29

def name
  return @name
end

#node_typeObject



20
21
22
# File 'lib/vcdom/minidom/attr.rb', line 20

def node_type
  return Node::ATTRIBUTE_NODE
end

#owner_elementObject

ownerElement of type Element, readonly, introduced in DOM Level 2

The Element node this attribute is attached to or null if this attribute is not in use.


86
# File 'lib/vcdom/minidom/attr.rb', line 86

def owner_element; return @owner_element end

#specifiedObject

specified of type boolean, readonly

True if this attribute was explicitly given a value in the instance document, 
false otherwise. 
  #=> この属性 (specified ではなく Attr ノード) が, 文書中で明示的に値を与えられている場合は 
      true, 


101
102
103
# File 'lib/vcdom/minidom/attr.rb', line 101

def specified
  return true
end

#valueObject Also known as: node_value

value of type DOMString

On retrieval, the value of the attribute is returned as a string. 
Character and general entity references are replaced with their values. 
See also the method getAttribute on the Element interface.
On setting, this creates a Text node with the unparsed contents of the string, 
i.e. any characters that an XML processor would recognize as markup are instead 
treated as literal text. 
See also the method Element.setAttribute().
Some specialized implementations, such as some [SVG 1.1] implementations, 
may do normalization automatically, even after mutation; in such case, the 
value on retrieval may differ from the value on setting.

Exceptions on setting
  DOMException
    NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.


49
50
51
# File 'lib/vcdom/minidom/attr.rb', line 49

def value
  return self.text_content
end

#value=(value) ⇒ Object Also known as: node_value=



52
53
54
55
56
57
58
59
60
61
# File 'lib/vcdom/minidom/attr.rb', line 52

def value=( value )
  if self.is_readonly then
    raise DOMException.new( DOMException::NO_MODIFICATION_ALLOWED_ERR, 
            'This node is readonly.' )
  end
  if ! value.instance_of? String then
    raise TypeError.new( "The argument must be String object." )
  end
  self.text_content = value
end