Class: LibXML::XML::Schema::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/libxml/schema/element.rb,
ext/libxml/ruby_xml_schema_element.c

Instance Method Summary collapse

Instance Method Details

#annotationObject



77
78
79
80
81
82
83
# File 'ext/libxml/ruby_xml_schema_element.c', line 77

def annotation
  return if node.nil?
  annotations = node.children.select { |n| n.name == 'annotation' }
  annotations.map do |annotation|
    annotation.children.map(&:content).join("\n")
  end.join("\n")
end

#array?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/libxml/schema/element.rb', line 10

def array?
  max_occurs > 1
end

#elementsObject



14
15
16
# File 'lib/libxml/schema/element.rb', line 14

def elements
  type.elements
end

#max_occursObject



72
73
74
75
# File 'ext/libxml/ruby_xml_schema_element.c', line 72

static VALUE rxml_schema_element_max_occurs(VALUE self)
{
  return rb_iv_get(self, "@max");
}

#min_occursObject



67
68
69
70
# File 'ext/libxml/ruby_xml_schema_element.c', line 67

static VALUE rxml_schema_element_min_occurs(VALUE self)
{
  return rb_iv_get(self, "@min");
}

#nameObject



27
28
29
30
31
32
33
34
35
# File 'ext/libxml/ruby_xml_schema_element.c', line 27

static VALUE rxml_schema_element_name(VALUE self)
{
  xmlSchemaElementPtr xelem;

  Data_Get_Struct(self, xmlSchemaElement, xelem);


  QNIL_OR_STRING(xelem->name)
}

#namespaceObject



18
19
20
21
22
23
24
25
# File 'ext/libxml/ruby_xml_schema_element.c', line 18

static VALUE rxml_schema_element_namespace(VALUE self)
{
  xmlSchemaElementPtr xelem;

  Data_Get_Struct(self, xmlSchemaElement, xelem);

  QNIL_OR_STRING(xelem->targetNamespace)
}

#nodeObject



49
50
51
52
53
54
55
56
# File 'ext/libxml/ruby_xml_schema_element.c', line 49

static VALUE rxml_schema_element_node(VALUE self)
{
  xmlSchemaElementPtr xelem;

  Data_Get_Struct(self, xmlSchemaElement, xelem);

  return rxml_node_wrap(xelem->node);
}

#required?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/libxml/schema/element.rb', line 6

def required?
  !min_occurs.zero?
end

#typeObject



37
38
39
40
41
42
43
44
45
46
47
# File 'ext/libxml/ruby_xml_schema_element.c', line 37

static VALUE rxml_schema_element_type(VALUE self)
{
  xmlSchemaElementPtr xelem;
  xmlSchemaTypePtr xtype;

  Data_Get_Struct(self, xmlSchemaElement, xelem);

  xtype = xelem->subtypes;

  return rxml_wrap_schema_type((xmlSchemaTypePtr) xtype);
}

#valueObject



58
59
60
61
62
63
64
65
# File 'ext/libxml/ruby_xml_schema_element.c', line 58

static VALUE rxml_schema_element_value(VALUE self)
{
  xmlSchemaElementPtr xelem;

  Data_Get_Struct(self, xmlSchemaElement, xelem);

  QNIL_OR_STRING(xelem->value)
}