lumeohq / xsd-parser-rs

A xsd/wsdl => rust code generator written in rust
Apache License 2.0
100 stars 39 forks source link

Add support for elements with nested ComplexType #2

Closed LeonidKrutovsky closed 4 years ago

LeonidKrutovsky commented 4 years ago
<xs:element name="StringItems">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Item" type="xs:string" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
</xs:element>
LeonidKrutovsky commented 4 years ago

Rust does not support nested types. I think we can create a private namespace in targetNamespace (mod nested { ...) and describe all nested types there. Thus, we will be able to repeat the structure of the xsd document in rust code as closely as possible.

mod nested {
    pub struct StringItems{
        item: Vec<String>,
    }
}

type StringItems = nested::StringItems;

Type alias only for top-level elements (schema element children). For the elements with the parent sequence, it will be necessary to create the structure field with the type of nested.