lumeohq / xsd-parser-rs

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

Add xsd generation to wsdl generator #65

Closed LeonidKrutovsky closed 4 years ago

LeonidKrutovsky commented 4 years ago

In WSDL files have sections 'types' [0..*] in which the 'xsd:schema' items are located.

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" targetNamespace="http://www.onvif.org/ver10/device/wsdl">
  <wsdl:types>
    <xs:schema targetNamespace="http://www.onvif.org/ver10/device/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" elementFormDefault="qualified" version="18.12">
      <xs:import namespace="http://www.onvif.org/ver10/schema" schemaLocation="../../../ver10/schema/onvif.xsd"/>
      <xs:element name="GetServices">
....
  </wsdl:types>

We have a ready-made xsd-parser with function

pub fn parse_schema<'input>(schema: &Node<'_, 'input>) -> RsFile<'input>

And we have rust code generator for xsd with

pub fn generate_rs_file(&self, schema: &RsFile<'input>) -> String

In WSDL parser we have 'Definitions' struct with method

pub fn types(&self) -> &[Types]

and 'Types' struct with method

pub fn schemas(&self) -> Vec<Node<'_, '_>>'

You need to think of an aggregating level for two parsers and two generators with a convenient API for the end user.