Class: Nokogiri::XML::ElementContent

Inherits:
Object
  • Object
show all
Defined in:
lib/nokogiri/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

Instance Method Summary collapse

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



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

def document
  @document
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
14
15
16
17
18
# File 'ext/nokogiri/xml_element_content.c', line 11

static VALUE get_name(VALUE self)
{
  xmlElementContentPtr elem;
  Data_Get_Struct(self, xmlElementContent, elem);

  if(!elem->name) return Qnil;
  return NOKOGIRI_STR_NEW2(elem->name);
}

#occurObject

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



72
73
74
75
76
77
78
# File 'ext/nokogiri/xml_element_content.c', line 72

static VALUE get_occur(VALUE self)
{
  xmlElementContentPtr elem;
  Data_Get_Struct(self, xmlElementContent, elem);

  return INT2NUM((long)elem->ocur);
}

#prefixObject

Get the element content namespace prefix.



86
87
88
89
90
91
92
93
94
# File 'ext/nokogiri/xml_element_content.c', line 86

static VALUE get_prefix(VALUE self)
{
  xmlElementContentPtr elem;
  Data_Get_Struct(self, xmlElementContent, elem);

  if(!elem->prefix) return Qnil;

  return NOKOGIRI_STR_NEW2(elem->prefix);
}

#typeObject

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



27
28
29
30
31
32
33
# File 'ext/nokogiri/xml_element_content.c', line 27

static VALUE get_type(VALUE self)
{
  xmlElementContentPtr elem;
  Data_Get_Struct(self, xmlElementContent, elem);

  return INT2NUM((long)elem->type);
}