Class: LibXML::XML::Schema::Type
- Inherits:
-
Object
- Object
- LibXML::XML::Schema::Type
- Defined in:
- lib/libxml/schema/type.rb,
ext/libxml/ruby_xml_schema_type.c
Instance Attribute Summary collapse
- #kind ⇒ Object readonly
- #name ⇒ Object readonly
- #namespace ⇒ Object readonly
Instance Method Summary collapse
- #annotation ⇒ Object
-
#anonymous_subtypes ⇒ Object
call-seq: type.anonymous_subtypes -> Hash.
-
#anonymous_subtypes_recursively(parent = nil) ⇒ Object
call-seq: type.anonymous_subtypes_recursively -> Array.
- #attributes ⇒ Object
- #base ⇒ Object
- #elements ⇒ Object
- #facets ⇒ Object
-
#kind_name ⇒ Object
call-seq: type.kind_name -> String.
- #node ⇒ Object
Instance Attribute Details
#kind ⇒ Object (readonly)
#name ⇒ Object (readonly)
#namespace ⇒ Object (readonly)
Instance Method Details
#annotation ⇒ Object
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; TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, 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; } |
#anonymous_subtypes ⇒ Object
call-seq:
type.anonymous_subtypes -> Hash
Returns a Hash of child elements whose types are anonymous (inline complex types with no global name).
type.anonymous_subtypes
# => {"shipto" => #<Schema::Element>, "item" => #<Schema::Element>}
23 24 25 |
# File 'lib/libxml/schema/type.rb', line 23 def anonymous_subtypes elements.select { |_, e| e.type.name.nil? } end |
#anonymous_subtypes_recursively(parent = nil) ⇒ Object
call-seq:
type.anonymous_subtypes_recursively -> Array
Returns a flattened Array of Hashes mapping qualified names to anonymous Schema::Type instances, descending into nested types.
type.anonymous_subtypes_recursively
# => [{"shipto" => #<Schema::Type>}, {"item" => #<Schema::Type>}]
35 36 37 38 39 40 |
# File 'lib/libxml/schema/type.rb', line 35 def anonymous_subtypes_recursively(parent=nil) anonymous_subtypes.map do |element_name, e| [{[parent, element_name].compact.join('::') => e.type}, e.type.anonymous_subtypes_recursively(element_name)] end.flatten end |
#attributes ⇒ Object
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; TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, 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; } |
#base ⇒ Object
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; TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype); return (xtype->baseType != xtype) ? rxml_wrap_schema_type(xtype->baseType) : Qnil; } |
#elements ⇒ Object
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; TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype); rxmlSchemaCollectElements((xmlSchemaParticlePtr) xtype->subtypes, result); return result; } |
#facets ⇒ Object
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; TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, 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_name ⇒ Object
call-seq:
type.kind_name -> String
Returns the name of the constant that matches this type’s kind value.
schema.types['shiporderType'].kind_name
# => :XML_SCHEMA_TYPE_COMPLEX
11 12 13 |
# File 'lib/libxml/schema/type.rb', line 11 def kind_name Schema::Types.constants.find { |k| Schema::Types.const_get(k) == kind } end |
#node ⇒ Object
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; TypedData_Get_Struct(self, xmlSchemaType, &rxml_schema_type_type, xtype); return (xtype->node != NULL) ? rxml_node_wrap(xtype->node) : Qnil; } |