Class: Lutaml::Xml::Parsers::Xsd

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xml/parsers/xsd.rb

Overview

Parses XSD schema files into Lutaml::Xml::Schema::Xsd::Schema objects.

Delegates to lutaml-model’s XSD parser with lazy loading to avoid eager-loading ~50 XSD model classes when not parsing XSD.

Examples:

Parse an XSD file

schema = Lutaml::Xml::Parsers::Xsd.parse(File.new("schema.xsd"))

With location for resolving imports

schema = Lutaml::Xml::Parsers::Xsd.parse(
  File.new("schema.xsd"),
  location: "/path/to/schemas",
)

Class Method Summary collapse

Class Method Details

.parse(file, options = {}) ⇒ Lutaml::Xml::Schema::Xsd::Schema

Parameters:

  • file (File, IO)

    file object with XSD content

  • options (Hash) (defaults to: {})

    parsing options

Options Hash (options):

  • :location (String)

    base path for resolving schema imports

Returns:

  • (Lutaml::Xml::Schema::Xsd::Schema)


24
25
26
27
28
29
30
31
# File 'lib/lutaml/xml/parsers/xsd.rb', line 24

def self.parse(file, options = {})
  require "lutaml/xml/schema/xsd"

  Lutaml::Xml::Schema::Xsd.parse(
    file.read,
    location: options[:location],
  )
end