Class: Canon::Xml::Nodes::NamespaceNode

Inherits:
Canon::Xml::Node show all
Defined in:
lib/canon/xml/nodes/namespace_node.rb

Overview

Namespace node in the XPath data model

Instance Attribute Summary collapse

Attributes inherited from Canon::Xml::Node

#children, #parent

Instance Method Summary collapse

Methods inherited from Canon::Xml::Node

#add_child, #in_node_set=, #in_node_set?

Constructor Details

#initialize(prefix:, uri:) ⇒ NamespaceNode

Returns a new instance of NamespaceNode.



12
13
14
15
16
# File 'lib/canon/xml/nodes/namespace_node.rb', line 12

def initialize(prefix:, uri:)
  super()
  @prefix = prefix
  @uri = uri
end

Instance Attribute Details

#prefixObject (readonly)

Returns the value of attribute prefix.



10
11
12
# File 'lib/canon/xml/nodes/namespace_node.rb', line 10

def prefix
  @prefix
end

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/canon/xml/nodes/namespace_node.rb', line 10

def uri
  @uri
end

Instance Method Details

#default_namespace?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/canon/xml/nodes/namespace_node.rb', line 31

def default_namespace?
  prefix.nil? || prefix.empty?
end

#local_nameObject

Local name is the prefix (empty string for default namespace)



27
28
29
# File 'lib/canon/xml/nodes/namespace_node.rb', line 27

def local_name
  prefix.to_s
end

#nameObject



18
19
20
# File 'lib/canon/xml/nodes/namespace_node.rb', line 18

def name
  prefix.to_s
end

#node_infoObject



40
41
42
# File 'lib/canon/xml/nodes/namespace_node.rb', line 40

def node_info
  "prefix: #{prefix} uri: #{uri}"
end

#node_typeObject



22
23
24
# File 'lib/canon/xml/nodes/namespace_node.rb', line 22

def node_type
  :namespace
end

#xml_namespace?Boolean

Check if this is the xml namespace

Returns:

  • (Boolean)


36
37
38
# File 'lib/canon/xml/nodes/namespace_node.rb', line 36

def xml_namespace?
  prefix == "xml" && uri == "http://www.w3.org/XML/1998/namespace"
end