Class: LibXML::XML::Schema::Type

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#kindObject (readonly)

#nameObject (readonly)

#namespaceObject (readonly)

Instance Method Details

#annonymus_subtypesObject



8
9
10
# File 'lib/libxml/schema/type.rb', line 8

def annonymus_subtypes
  elements.select { |_, e| e.type.name.nil? }
end

#annonymus_subtypes_recursively(parent = nil) ⇒ Object



12
13
14
15
16
17
# File 'lib/libxml/schema/type.rb', line 12

def annonymus_subtypes_recursively(parent=nil)
  annonymus_subtypes.map do |element_name, e|
    [{[parent, element_name].compact.join('::') => e.type},
     e.type.annonymus_subtypes_recursively(element_name)]
  end.flatten
end

#annotationObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'ext/libxml/ruby_xml_schema_type.c', line 110

static VALUE rxml_schema_type_annot(VALUE self)
{
  VALUE result = Qnil;
  xmlSchemaTypePtr xtype;

  Data_Get_Struct(self, xmlSchemaType, xtype);

  if(xtype != NULL && xtype->annot != NULL && xtype->annot->content != NULL)
  {
    xmlChar *content = xmlNodeGetContent(xtype->annot->content);
	if (content)
	{
	  result = rxml_new_cstr(content, NULL);
	  xmlFree(content);
    }
  }
  return result;
}

#attributesObject



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'ext/libxml/ruby_xml_schema_type.c', line 207

static VALUE rxml_schema_type_attributes(VALUE self)
{
  VALUE result = rb_ary_new();
  xmlSchemaTypePtr xtype;
  xmlSchemaAttributeUsePtr xuse;
  xmlSchemaItemListPtr xuses;
  int i;

  Data_Get_Struct(self, xmlSchemaType, xtype);
  xuses = xtype->attrUses;

  if (xuses != NULL)
  {
    for (i = 0; i < xuses->nbItems; i++)
	{
      xuse = (xmlSchemaAttributeUsePtr)xuses->items[i];
      rb_ary_push(result, rxml_wrap_schema_attribute(xuse));
    }
  }

  return result;
}

#baseObject



71
72
73
74
75
76
77
78
# File 'ext/libxml/ruby_xml_schema_type.c', line 71

static VALUE rxml_schema_type_base(VALUE self)
{
  xmlSchemaTypePtr xtype;

  Data_Get_Struct(self, xmlSchemaType, xtype);

  return (xtype->baseType != xtype) ? rxml_wrap_schema_type(xtype->baseType) : Qnil;
}

#elementsObject



196
197
198
199
200
201
202
203
204
205
# File 'ext/libxml/ruby_xml_schema_type.c', line 196

static VALUE rxml_schema_type_elements(VALUE self)
{
  VALUE result = rb_hash_new();
  xmlSchemaTypePtr xtype;

  Data_Get_Struct(self, xmlSchemaType, xtype);
  rxmlSchemaCollectElements((xmlSchemaParticlePtr) xtype->subtypes, result);

  return result;
}

#facetsObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'ext/libxml/ruby_xml_schema_type.c', line 89

static VALUE rxml_schema_type_facets(VALUE self)
{
  xmlSchemaTypePtr xtype;
  xmlSchemaFacetPtr xfacet;
  VALUE result = rb_ary_new();
  VALUE facet;

  Data_Get_Struct(self, xmlSchemaType, xtype);

  xfacet = xtype->facets;

  while (xfacet != NULL)
  {
    facet = rxml_wrap_schema_facet((xmlSchemaFacetPtr)xfacet);
    rb_ary_push(result, facet);
    xfacet = xfacet->next;
  }

  return result;
}

#kind_nameObject



4
5
6
# File 'lib/libxml/schema/type.rb', line 4

def kind_name
  Schema::Types.constants.find { |k| Schema::Types.const_get(k) == kind }
end

#nodeObject



80
81
82
83
84
85
86
87
# File 'ext/libxml/ruby_xml_schema_type.c', line 80

static VALUE rxml_schema_type_node(VALUE self)
{
  xmlSchemaTypePtr xtype;

  Data_Get_Struct(self, xmlSchemaType, xtype);

  return (xtype->node != NULL) ? rxml_node_wrap(xtype->node) : Qnil;
}