Class: Lutaml::Xml::Schema::Builder
- Inherits:
-
Object
- Object
- Lutaml::Xml::Schema::Builder
- Defined in:
- lib/lutaml/xml/schema/builder.rb,
lib/lutaml/xml/schema/builder/oga.rb,
lib/lutaml/xml/schema/builder/nokogiri.rb
Overview
SchemaBuilder provides an adapter-agnostic interface for XSD schema generation It wraps XML builders (Nokogiri, Oga) to generate XSD documents
NOTE: Schema generation is separate from XML parsing. While the XML parsing adapters (Nokogiri, Oga, Ox, REXML) handle reading/writing XML documents, schema generation requires an XML builder API which is only implemented for Nokogiri and Oga. When the configured XML adapter is Ox or REXML, we use Nokogiri for schema generation since it has the most complete builder API.
Defined Under Namespace
Constant Summary collapse
- SUPPORTED_BUILDERS =
Supported schema builders (separate from XML parsing adapters)
%i[nokogiri oga].freeze
Instance Attribute Summary collapse
-
#adapter_type ⇒ Object
readonly
Returns the value of attribute adapter_type.
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
Instance Method Summary collapse
-
#initialize(adapter_type: nil, options: {}) ⇒ Builder
constructor
A new instance of Builder.
-
#to_xml(options = {}) ⇒ String
Generate the XSD schema XML string.
Constructor Details
#initialize(adapter_type: nil, options: {}) ⇒ Builder
Returns a new instance of Builder.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lutaml/xml/schema/builder.rb', line 23 def initialize(adapter_type: nil, options: {}, &) # Use specified adapter, or configured XML adapter, or default to Nokogiri requested_adapter = adapter_type || Lutaml::Model::Config.xml_adapter_type || :nokogiri # Schema generation requires a builder API which only Nokogiri and Oga provide # Ox and REXML are valid XML parsing adapters but don't have schema builder implementations @adapter_type = if SUPPORTED_BUILDERS.include?(requested_adapter) requested_adapter else :nokogiri end @options = @builder = create_builder(&) end |
Instance Attribute Details
#adapter_type ⇒ Object (readonly)
Returns the value of attribute adapter_type.
18 19 20 |
# File 'lib/lutaml/xml/schema/builder.rb', line 18 def adapter_type @adapter_type end |
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
18 19 20 |
# File 'lib/lutaml/xml/schema/builder.rb', line 18 def builder @builder end |
Instance Method Details
#to_xml(options = {}) ⇒ String
Generate the XSD schema XML string
42 43 44 |
# File 'lib/lutaml/xml/schema/builder.rb', line 42 def to_xml( = {}) @builder.to_xml() end |