oa_gateway_uci::xsd::assemble

Function compile

Source
pub fn compile(documents: &[&str]) -> Result<Schema, UciError>
Expand description

Compile XSD documents into a single Schema.

Pass every document the schema spans; xs:include and xs:import directives are not followed, because resolving them would mean reading paths out of the schema text. Anything left dangling is reported by name, so a forgotten document surfaces as a clear error rather than a missing type at conversion time.

§Errors

Returns UciError::Xsd if a document is not well-formed, uses a construct outside the supported subset, defines the same name twice, or leaves a type reference unresolved.

§Examples

let schema = xsd::compile(&[r#"
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
               xmlns:uci="urn:example"
               targetNamespace="urn:example">
      <xs:element name="Ping" type="uci:PingType"/>
      <xs:complexType name="PingType">
        <xs:sequence>
          <xs:element name="n" type="xs:int" minOccurs="0"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
"#])?;

assert_eq!(schema.global_type("Ping"), Some("PingType"));