Class: LibXML::XML::Schema
| Relationships & Source Files | |
| Namespace Children | |
|
Modules:
| |
|
Classes:
| |
| Inherits: | Object |
| Defined in: | ext/libxml/ruby_xml_schema.c, lib/libxml/schema.rb |
Class Method Summary
-
XML::Schema.document(document) ⇒ Schema
Create a new schema from the specified document.
-
XML::Schema.from_string("schema_data") ⇒ "value"
Create a new schema using the specified string.
-
XML::Schema.initialize(schema_uri) ⇒ Schema
constructor
Create a new schema from the specified URI.
Instance Attribute Summary
- #id readonly
- #name readonly
-
#target_namespace
readonly
Create attr_reader methods for the above instance variables.
- #version readonly
Instance Method Summary
-
XML::Schema.document ⇒ document
Return the
SchemaXMLDocument. - #elements
-
XML::Schema.imported_ns_elements ⇒ Hash
Returns a hash by namespace of a hash of schema elements within the entire schema including imports.
-
XML::Schema.imported_ns_types ⇒ Hash
Returns a hash by namespace of a hash of schema types within the entire schema including imports.
-
XML::Schema.imported_types ⇒ Hash
Returns a hash of all types within the entire schema including imports.
-
XML::Schema.namespaces ⇒ Array
Returns an array of
Namespacesdefined by the schema. - #types
Constructor Details
XML::Schema.initialize(schema_uri) ⇒ Schema
Create a new schema from the specified URI.
# File 'ext/libxml/ruby_xml_schema.c', line 157
static VALUE rxml_schema_init_from_uri(VALUE class, VALUE uri)
{
xmlSchemaParserCtxtPtr xparser;
Check_Type(uri, T_STRING);
xmlResetLastError();
xparser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
if (!xparser)
rxml_raise(xmlGetLastError());
return rxml_schema_init(class, xparser);
}
Class Method Details
XML::Schema.document(document) ⇒ Schema
Create a new schema from the specified document.
# File 'ext/libxml/ruby_xml_schema.c', line 177
static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
{
xmlDocPtr xdoc;
xmlSchemaParserCtxtPtr xparser;
Data_Get_Struct(document, xmlDoc, xdoc);
xmlResetLastError();
xparser = xmlSchemaNewDocParserCtxt(xdoc);
if (!xparser)
rxml_raise(xmlGetLastError());
return rxml_schema_init(class, xparser);
}
XML::Schema.from_string("schema_data") ⇒ "value"
Create a new schema using the specified string.
# File 'ext/libxml/ruby_xml_schema.c', line 198
static VALUE rxml_schema_init_from_string(VALUE class, VALUE schema_str)
{
xmlSchemaParserCtxtPtr xparser;
Check_Type(schema_str, T_STRING);
xmlResetLastError();
xparser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), (int)strlen(StringValuePtr(schema_str)));
if (!xparser)
rxml_raise(xmlGetLastError());
return rxml_schema_init(class, xparser);
}
Instance Attribute Details
#id (readonly)
[ GitHub ]#name (readonly)
[ GitHub ]#target_namespace (readonly)
Create attr_reader methods for the above instance variables
#version (readonly)
[ GitHub ]Instance Method Details
XML::Schema.document ⇒ document
Return the Schema XML Document
# File 'ext/libxml/ruby_xml_schema.c', line 218
static VALUE rxml_schema_document(VALUE self)
{
xmlSchemaPtr xschema;
Data_Get_Struct(self, xmlSchema, xschema);
return rxml_node_wrap(xmlDocGetRootElement(xschema->doc));
}
#elements
[ GitHub ]# File 'ext/libxml/ruby_xml_schema.c', line 271
static VALUE rxml_schema_elements(VALUE self)
{
VALUE result = rb_hash_new();
xmlSchemaPtr xschema;
Data_Get_Struct(self, xmlSchema, xschema);
xmlHashScan(xschema->elemDecl, (xmlHashScanner)scan_schema_element, (void *)result);
return result;
}
XML::Schema.imported_ns_elements ⇒ Hash
Returns a hash by namespace of a hash of schema elements within the entire schema including imports
# File 'ext/libxml/ruby_xml_schema.c', line 298
static VALUE rxml_schema_imported_ns_elements(VALUE self)
{
xmlSchemaPtr xschema;
VALUE result = rb_hash_new();
Data_Get_Struct(self, xmlSchema, xschema);
if (xschema)
{
xmlHashScan(xschema->schemasImports, (xmlHashScanner)collect_imported_ns_elements, (void *)result);
}
return result;
}
XML::Schema.imported_ns_types ⇒ Hash
Returns a hash by namespace of a hash of schema types within the entire schema including imports
# File 'ext/libxml/ruby_xml_schema.c', line 379
static VALUE rxml_schema_imported_ns_types(VALUE self)
{
xmlSchemaPtr xschema;
VALUE result = rb_hash_new();
Data_Get_Struct(self, xmlSchema, xschema);
if (xschema)
{
xmlHashScan(xschema->schemasImports, (xmlHashScanner)collect_imported_ns_types, (void *)result);
}
return result;
}
XML::Schema.imported_types ⇒ Hash
Returns a hash of all types within the entire schema including imports
# File 'ext/libxml/ruby_xml_schema.c', line 348
static VALUE rxml_schema_imported_types(VALUE self)
{
xmlSchemaPtr xschema;
VALUE result = rb_hash_new();
Data_Get_Struct(self, xmlSchema, xschema);
if (xschema)
{
xmlHashScan(xschema->schemasImports, (xmlHashScanner)collect_imported_types, (void *)result);
}
return result;
}
XML::Schema.namespaces ⇒ Array
Returns an array of Namespaces defined by the schema
# File 'ext/libxml/ruby_xml_schema.c', line 252
static VALUE rxml_schema_namespaces(VALUE self)
{
VALUE result;
xmlSchemaPtr xschema;
Data_Get_Struct(self, xmlSchema, xschema);
result = rb_ary_new();
xmlHashScan(xschema->schemasImports, (xmlHashScanner)scan_namespaces, (void *)result);
return result;
}
#types
[ GitHub ]# File 'ext/libxml/ruby_xml_schema.c', line 319
static VALUE rxml_schema_types(VALUE self)
{
VALUE result = rb_hash_new();
xmlSchemaPtr xschema;
Data_Get_Struct(self, xmlSchema, xschema);
if (xschema != NULL && xschema->typeDecl != NULL)
{
xmlHashScan(xschema->typeDecl, (xmlHashScanner)scan_schema_type, (void *)result);
}
return result;
}