123456789_123456789_123456789_123456789_123456789_

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

Instance Attribute Summary

Instance Method Summary

Constructor Details

XML::Schema.initialize(schema_uri) ⇒ Schema

Create a new schema from the specified URI.

[ GitHub ]

  
# 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.

[ GitHub ]

  
# 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.

[ GitHub ]

  
# 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

[ GitHub ]

#version (readonly)

[ GitHub ]

Instance Method Details

XML::Schema.document ⇒ document

Return the Schema XML Document

[ GitHub ]

  
# 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_elementsHash

Returns a hash by namespace of a hash of schema elements within the entire schema including imports

[ GitHub ]

  
# 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_typesHash

Returns a hash by namespace of a hash of schema types within the entire schema including imports

[ GitHub ]

  
# 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_typesHash

Returns a hash of all types within the entire schema including imports

[ GitHub ]

  
# 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.namespacesArray

Returns an array of Namespaces defined by the schema

[ GitHub ]

  
# 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;
}