Class: Ea::Export::Xsd::Generator
- Inherits:
-
Object
- Object
- Ea::Export::Xsd::Generator
- Defined in:
- lib/ea/export/xsd/generator.rb
Overview
Generates an XSD schema string from a parsed QEA model.
Pure: takes already-loaded ClassMapping and NamespaceRegistry instances. No file IO, no fixture-path coupling. The CLI layer is responsible for loading GMLClassMapping.xml and GMLNamespaces.xml from disk.
Defined Under Namespace
Classes: Classifier
Constant Summary collapse
- XSD_NS =
"http://www.w3.org/2001/XMLSchema"
Instance Attribute Summary collapse
-
#class_mapping ⇒ Object
readonly
Returns the value of attribute class_mapping.
-
#namespaces ⇒ Object
readonly
Returns the value of attribute namespaces.
Class Method Summary collapse
-
.call(model, target_namespace: "http://example.com/xsd", prefix: "tns", **opts) ⇒ Object
Class-method shortcut.
Instance Method Summary collapse
-
#call(model, target_namespace:, prefix: "tns") ⇒ String
Generate an XSD schema for the given model.
-
#initialize(class_mapping: ClassMapping.new, namespaces: NamespaceRegistry.new) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(class_mapping: ClassMapping.new, namespaces: NamespaceRegistry.new) ⇒ Generator
Returns a new instance of Generator.
21 22 23 24 25 |
# File 'lib/ea/export/xsd/generator.rb', line 21 def initialize(class_mapping: ClassMapping.new, namespaces: NamespaceRegistry.new) @class_mapping = class_mapping @namespaces = namespaces end |
Instance Attribute Details
#class_mapping ⇒ Object (readonly)
Returns the value of attribute class_mapping.
17 18 19 |
# File 'lib/ea/export/xsd/generator.rb', line 17 def class_mapping @class_mapping end |
#namespaces ⇒ Object (readonly)
Returns the value of attribute namespaces.
17 18 19 |
# File 'lib/ea/export/xsd/generator.rb', line 17 def namespaces @namespaces end |
Class Method Details
.call(model, target_namespace: "http://example.com/xsd", prefix: "tns", **opts) ⇒ Object
Class-method shortcut. Accepts the same options as #initialize via keyword args.
29 30 31 32 |
# File 'lib/ea/export/xsd/generator.rb', line 29 def self.call(model, target_namespace: "http://example.com/xsd", prefix: "tns", **opts) new(**opts).call(model, target_namespace: target_namespace, prefix: prefix) end |
Instance Method Details
#call(model, target_namespace:, prefix: "tns") ⇒ String
Generate an XSD schema for the given model.
40 41 42 43 44 |
# File 'lib/ea/export/xsd/generator.rb', line 40 def call(model, target_namespace:, prefix: "tns") doc = build_schema_doc(target_namespace, prefix) walk_model(model, doc) doc.to_xml(indent: 2) end |