Class: Nokogiri::XML::ElementContent

Inherits:
Object
  • Object
show all
Defined in:
lib/nokogiri/xml/element_content.rb,
lib/nokogiri/ffi/xml/element_content.rb,
ext/nokogiri/xml_element_content.c

Overview

Represents the allowed content in an Element Declaration inside a DTD:

<?xml version="1.0"?><?TEST-STYLE PIDATA?>
<!DOCTYPE staff SYSTEM "staff.dtd" [
   <!ELEMENT div1 (head, (p | list | note)*, div2*)>
]>
</root>

ElementContent represents the tree inside the <!ELEMENT> tag shown above that lists the possible content for the div1 tag.

Constant Summary collapse

PCDATA =

Possible definitions of type

1
ELEMENT =
2
SEQ =
3
OR =
4
ONCE =

Possible content occurrences

1
OPT =
2
MULT =
3
PLUS =
4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cstructObject

Returns the value of attribute cstruct.



5
6
7
# File 'lib/nokogiri/ffi/xml/element_content.rb', line 5

def cstruct
  @cstruct
end

#documentObject (readonly)

Returns the value of attribute document.



27
28
29
# File 'lib/nokogiri/xml/element_content.rb', line 27

def document
  @document
end

Class Method Details

.wrap(pointer, document) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/nokogiri/ffi/xml/element_content.rb', line 7

def self.wrap pointer, document
  return nil if pointer.null?

  c = ElementContent.allocate
  c.cstruct = LibXML::XmlElementContent.new pointer
  c.instance_variable_set :@document, document
  c
end

Instance Method Details

#childrenObject

Get the children of this ElementContent node



31
32
33
# File 'lib/nokogiri/xml/element_content.rb', line 31

def children
  [c1, c2].compact
end

#nameObject

Get the require element name



11
12
13
# File 'ext/nokogiri/xml_element_content.c', line 11

def name
  cstruct[:name]
end

#occurObject

Get the element content occur flag. Possible values are ONCE, OPT, MULT or PLUS.



72
73
74
# File 'ext/nokogiri/xml_element_content.c', line 72

def occur
  cstruct[:ocur]
end

#prefixObject

Get the element content namespace prefix.



86
87
88
# File 'ext/nokogiri/xml_element_content.c', line 86

def prefix
  cstruct[:prefix]
end

#typeObject

Get the element content type. Possible values are PCDATA, ELEMENT, SEQ, or OR.



27
28
29
# File 'ext/nokogiri/xml_element_content.c', line 27

def type
  cstruct[:type]
end