Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 0.10.0
    • XML/XSD - Compiler
    • None

    Description

      I've put together an XML model for Thrift IDL that is very similar in concept and structure to the model created by the JSON generator of the Thrift compiler. The code is based on the JSON generator, and inherits the 'merge' option from that module for including the model of all includes in a single file if desired.

      This generator is useful if you wish to extend the Thrift compiler with some XML based templating engine such as XSLT. For example I have prototyped transforms that can create valid XML schema and WSDL files from Thrift IDL, as well as transform SOAP requests and responses to and from Thrift messages. Those transforms are not included because they may be outside the scope of Thrift, but I can provide them if interested. Regardless, I feel the XML model is generally useful and might be a good addition to the Thrift compiler.

      Also included is an XML schema for the model file format and tests that generate XML from existing IDL in the Thrift test suite to validate against that schema. These tests are Ant based and so only run when --with-java is enabled in ./configure

      Attachments

        1. transforms.tar.gz
          7 kB
          Benjamin Gould

        Activity

          githubbot ASF GitHub Bot added a comment -

          GitHub user bgould opened a pull request:

          https://github.com/apache/thrift/pull/774

          THRIFT-3523 : XML Generator

          I've put together an XML model for Thrift IDL that is very similar in concept and structure to the model created by the JSON generator of the Thrift compiler. The code is based on the JSON generator, and inherits the 'merge' option from that module for including the model of all includes in a single file if desired.

          This generator is useful if you wish to extend the Thrift compiler with some XML based templating engine such as XSLT. For example I have prototyped transforms that can create valid XML schema and WSDL files from Thrift IDL, as well as transform SOAP requests and responses to and from Thrift messages. Those transforms are not included because they may be outside the scope of Thrift, but I can provide them if interested. Regardless, I feel the XML model is generally useful and might be a good addition to the Thrift compiler.

          Also included is an XML schema for the model file format and tests that generate XML from existing IDL in the Thrift test suite to validate against that schema. These tests are Ant based and so only run when --with-java is enabled in ./configure

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/bgould/thrift xml-generator

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/thrift/pull/774.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #774


          commit e09407675ea70a5bc4d5d25bfa2174e1518acf0c
          Author: BCG <bgould@users.noreply.github.com>
          Date: 2015-12-28T06:15:00Z

          Added XML generator.


          githubbot ASF GitHub Bot added a comment - GitHub user bgould opened a pull request: https://github.com/apache/thrift/pull/774 THRIFT-3523 : XML Generator I've put together an XML model for Thrift IDL that is very similar in concept and structure to the model created by the JSON generator of the Thrift compiler. The code is based on the JSON generator, and inherits the 'merge' option from that module for including the model of all includes in a single file if desired. This generator is useful if you wish to extend the Thrift compiler with some XML based templating engine such as XSLT. For example I have prototyped transforms that can create valid XML schema and WSDL files from Thrift IDL, as well as transform SOAP requests and responses to and from Thrift messages. Those transforms are not included because they may be outside the scope of Thrift, but I can provide them if interested. Regardless, I feel the XML model is generally useful and might be a good addition to the Thrift compiler. Also included is an XML schema for the model file format and tests that generate XML from existing IDL in the Thrift test suite to validate against that schema. These tests are Ant based and so only run when --with-java is enabled in ./configure You can merge this pull request into a Git repository by running: $ git pull https://github.com/bgould/thrift xml-generator Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/774.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #774 commit e09407675ea70a5bc4d5d25bfa2174e1518acf0c Author: BCG <bgould@users.noreply.github.com> Date: 2015-12-28T06:15:00Z Added XML generator.
          jensg Jens Geyer added a comment -

          Great stuff, I'll take al look at it.

          jensg Jens Geyer added a comment - Great stuff, I'll take al look at it.
          githubbot ASF GitHub Bot added a comment -

          Github user Jens-G commented on a diff in the pull request:

          https://github.com/apache/thrift/pull/774#discussion_r49244219

          — Diff: lib/xml/thrift-idl.xsd —
          @@ -0,0 +1,265 @@
          +<?xml version="1.0" encoding="UTF-8"?>
          +<schema xmlns="http://www.w3.org/2001/XMLSchema"
          + targetNamespace="http://thrift.apache.org/xml/idl"
          + xmlns:tns="http://thrift.apache.org/xml/idl"
          + elementFormDefault="qualified">
          +
          + <element name="idl" type="tns:IDL" />
          + <element name="document" type="tns:Document" />
          +
          + <complexType name="IDL">
          + <sequence>
          + <element ref="tns:document" minOccurs="1" maxOccurs="unbounded"/>
          + </sequence>
          + </complexType>
          +
          + <complexType name="Document">
          + <sequence>
          + <choice minOccurs="0" maxOccurs="unbounded">
          + <element name="include" type="tns:Include" />
          + <element name="namespace" type="tns:Namespace" />
          + </choice>
          + <choice minOccurs="0" maxOccurs="unbounded">
          + <element name="exception" type="tns:Exception" />
          + <element name="typedef" type="tns:Typedef" />
          + <element name="service" type="tns:Service" />
          + <element name="struct" type="tns:Struct" />
          + <element name="const" type="tns:Const" />
          + <element name="union" type="tns:Union" />
          + <element name="enum" type="tns:Enum" />
          + </choice>
          + </sequence>
          + <attribute name="name" type="string" />
          + <attribute name="targetNamespace" type="anyURI" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Include">
          + <attribute name="file" type="string" />
          + <attribute name="name" type="string" />
          + </complexType>
          +
          + <complexType name="Namespace">
          + <sequence>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" />
          + <attribute name="value" type="string" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <group name="AbstractStruct">
          + <sequence>
          + <element name="field" type="tns:Field"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + </group>
          +
          + <attributeGroup name="StructAttributes">
          + <attribute name="name" type="string" />
          + <attribute name="doc" type="string" />
          + </attributeGroup>
          +
          + <complexType name="Exception">
          + <group ref="tns:AbstractStruct" />
          + <attributeGroup ref="tns:StructAttributes" />
          + </complexType>
          +
          + <complexType name="Service">
          + <sequence>
          + <element name="method" type="tns:Method"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="targetNamespace" type="string" use="required" />
          + <attribute name="parent-module" type="string" use="optional" />
          + <attribute name="parent-id" type="string" use="optional" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Method">
          + <sequence>
          + <element name="returns" type="tns:ThriftType" />
          + <element name="arg" type="tns:Field"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="throws" type="tns:Field"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="oneway" type="boolean" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Typedef">
          + <complexContent>
          + <extension base="tns:ThriftType">
          + <sequence>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="doc" type="string" />
          + </extension>
          + </complexContent>
          + </complexType>
          +
          + <complexType name="Struct">
          + <group ref="tns:AbstractStruct" />
          + <attributeGroup ref="tns:StructAttributes" />
          + </complexType>
          +
          + <complexType name="Union">
          + <group ref="tns:AbstractStruct" />
          + <attributeGroup ref="tns:StructAttributes" />
          + </complexType>
          +
          + <complexType name="Enum">
          + <sequence>
          + <element name="member" minOccurs="1" maxOccurs="unbounded">
          + <complexType>
          + <sequence>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="value" type="int" />
          + <attribute name="explicit" type="boolean" />
          + <attribute name="doc" type="string" />
          + </complexType>
          + </element>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Field">
          + <complexContent>
          + <extension base="tns:ThriftType">
          + <sequence>
          + <element name="default" minOccurs="0" maxOccurs="1">
          + <complexType>
          + <group ref="tns:ConstValue" />
          + </complexType>
          + </element>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="field-id" type="long" />
          + <attribute name="name" type="string" use="required" />
          + <attribute name="required" type="tns:Requiredness" />
          + <attribute name="doc" type="string" />
          + </extension>
          + </complexContent>
          + </complexType>
          +
          + <simpleType name="Requiredness">
          + <restriction base="string">
          + <enumeration value="required" />
          + <enumeration value="optional" />
          + </restriction>
          — End diff –

          If I read this correctly, the ```<attribute name="required" type="tns:Requiredness" />``` must be specified. But there are only two possible values for it. We have three ... if neither ```required``` nor ```optional``` are specified, the member is of the so-called "default" requiredness (which basically says: it may not be in the data you read, but please always write it).

          githubbot ASF GitHub Bot added a comment - Github user Jens-G commented on a diff in the pull request: https://github.com/apache/thrift/pull/774#discussion_r49244219 — Diff: lib/xml/thrift-idl.xsd — @@ -0,0 +1,265 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://thrift.apache.org/xml/idl" + xmlns:tns="http://thrift.apache.org/xml/idl" + elementFormDefault="qualified"> + + <element name="idl" type="tns:IDL" /> + <element name="document" type="tns:Document" /> + + <complexType name="IDL"> + <sequence> + <element ref="tns:document" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="Document"> + <sequence> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="include" type="tns:Include" /> + <element name="namespace" type="tns:Namespace" /> + </choice> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="exception" type="tns:Exception" /> + <element name="typedef" type="tns:Typedef" /> + <element name="service" type="tns:Service" /> + <element name="struct" type="tns:Struct" /> + <element name="const" type="tns:Const" /> + <element name="union" type="tns:Union" /> + <element name="enum" type="tns:Enum" /> + </choice> + </sequence> + <attribute name="name" type="string" /> + <attribute name="targetNamespace" type="anyURI" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Include"> + <attribute name="file" type="string" /> + <attribute name="name" type="string" /> + </complexType> + + <complexType name="Namespace"> + <sequence> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" /> + <attribute name="value" type="string" /> + <attribute name="doc" type="string" /> + </complexType> + + <group name="AbstractStruct"> + <sequence> + <element name="field" type="tns:Field" + minOccurs="0" maxOccurs="unbounded" /> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </group> + + <attributeGroup name="StructAttributes"> + <attribute name="name" type="string" /> + <attribute name="doc" type="string" /> + </attributeGroup> + + <complexType name="Exception"> + <group ref="tns:AbstractStruct" /> + <attributeGroup ref="tns:StructAttributes" /> + </complexType> + + <complexType name="Service"> + <sequence> + <element name="method" type="tns:Method" + minOccurs="0" maxOccurs="unbounded" /> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="targetNamespace" type="string" use="required" /> + <attribute name="parent-module" type="string" use="optional" /> + <attribute name="parent-id" type="string" use="optional" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Method"> + <sequence> + <element name="returns" type="tns:ThriftType" /> + <element name="arg" type="tns:Field" + minOccurs="0" maxOccurs="unbounded" /> + <element name="throws" type="tns:Field" + minOccurs="0" maxOccurs="unbounded" /> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="oneway" type="boolean" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Typedef"> + <complexContent> + <extension base="tns:ThriftType"> + <sequence> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="doc" type="string" /> + </extension> + </complexContent> + </complexType> + + <complexType name="Struct"> + <group ref="tns:AbstractStruct" /> + <attributeGroup ref="tns:StructAttributes" /> + </complexType> + + <complexType name="Union"> + <group ref="tns:AbstractStruct" /> + <attributeGroup ref="tns:StructAttributes" /> + </complexType> + + <complexType name="Enum"> + <sequence> + <element name="member" minOccurs="1" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="value" type="int" /> + <attribute name="explicit" type="boolean" /> + <attribute name="doc" type="string" /> + </complexType> + </element> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Field"> + <complexContent> + <extension base="tns:ThriftType"> + <sequence> + <element name="default" minOccurs="0" maxOccurs="1"> + <complexType> + <group ref="tns:ConstValue" /> + </complexType> + </element> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="field-id" type="long" /> + <attribute name="name" type="string" use="required" /> + <attribute name="required" type="tns:Requiredness" /> + <attribute name="doc" type="string" /> + </extension> + </complexContent> + </complexType> + + <simpleType name="Requiredness"> + <restriction base="string"> + <enumeration value="required" /> + <enumeration value="optional" /> + </restriction> — End diff – If I read this correctly, the ```<attribute name="required" type="tns:Requiredness" />``` must be specified. But there are only two possible values for it. We have three ... if neither ```required``` nor ```optional``` are specified, the member is of the so-called "default" requiredness (which basically says: it may not be in the data you read, but please always write it).
          githubbot ASF GitHub Bot added a comment -

          Github user Jens-G commented on a diff in the pull request:

          https://github.com/apache/thrift/pull/774#discussion_r49244531

          — Diff: lib/xml/thrift-idl.xsd —
          @@ -0,0 +1,265 @@
          +<?xml version="1.0" encoding="UTF-8"?>
          +<schema xmlns="http://www.w3.org/2001/XMLSchema"
          + targetNamespace="http://thrift.apache.org/xml/idl"
          + xmlns:tns="http://thrift.apache.org/xml/idl"
          + elementFormDefault="qualified">
          +
          + <element name="idl" type="tns:IDL" />
          + <element name="document" type="tns:Document" />
          +
          + <complexType name="IDL">
          + <sequence>
          + <element ref="tns:document" minOccurs="1" maxOccurs="unbounded"/>
          + </sequence>
          + </complexType>
          +
          + <complexType name="Document">
          + <sequence>
          + <choice minOccurs="0" maxOccurs="unbounded">
          + <element name="include" type="tns:Include" />
          + <element name="namespace" type="tns:Namespace" />
          + </choice>
          + <choice minOccurs="0" maxOccurs="unbounded">
          + <element name="exception" type="tns:Exception" />
          + <element name="typedef" type="tns:Typedef" />
          + <element name="service" type="tns:Service" />
          + <element name="struct" type="tns:Struct" />
          + <element name="const" type="tns:Const" />
          + <element name="union" type="tns:Union" />
          + <element name="enum" type="tns:Enum" />
          + </choice>
          + </sequence>
          + <attribute name="name" type="string" />
          + <attribute name="targetNamespace" type="anyURI" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Include">
          + <attribute name="file" type="string" />
          + <attribute name="name" type="string" />
          + </complexType>
          +
          + <complexType name="Namespace">
          + <sequence>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" />
          + <attribute name="value" type="string" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <group name="AbstractStruct">
          + <sequence>
          + <element name="field" type="tns:Field"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + </group>
          +
          + <attributeGroup name="StructAttributes">
          + <attribute name="name" type="string" />
          + <attribute name="doc" type="string" />
          + </attributeGroup>
          +
          + <complexType name="Exception">
          + <group ref="tns:AbstractStruct" />
          + <attributeGroup ref="tns:StructAttributes" />
          + </complexType>
          +
          + <complexType name="Service">
          + <sequence>
          + <element name="method" type="tns:Method"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="targetNamespace" type="string" use="required" />
          + <attribute name="parent-module" type="string" use="optional" />
          + <attribute name="parent-id" type="string" use="optional" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Method">
          + <sequence>
          + <element name="returns" type="tns:ThriftType" />
          + <element name="arg" type="tns:Field"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="throws" type="tns:Field"
          + minOccurs="0" maxOccurs="unbounded" />
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="oneway" type="boolean" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Typedef">
          + <complexContent>
          + <extension base="tns:ThriftType">
          + <sequence>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="doc" type="string" />
          + </extension>
          + </complexContent>
          + </complexType>
          +
          + <complexType name="Struct">
          + <group ref="tns:AbstractStruct" />
          + <attributeGroup ref="tns:StructAttributes" />
          + </complexType>
          +
          + <complexType name="Union">
          + <group ref="tns:AbstractStruct" />
          + <attributeGroup ref="tns:StructAttributes" />
          + </complexType>
          +
          + <complexType name="Enum">
          + <sequence>
          + <element name="member" minOccurs="1" maxOccurs="unbounded">
          + <complexType>
          + <sequence>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="value" type="int" />
          + <attribute name="explicit" type="boolean" />
          + <attribute name="doc" type="string" />
          + </complexType>
          + </element>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="name" type="string" use="required" />
          + <attribute name="doc" type="string" />
          + </complexType>
          +
          + <complexType name="Field">
          + <complexContent>
          + <extension base="tns:ThriftType">
          + <sequence>
          + <element name="default" minOccurs="0" maxOccurs="1">
          + <complexType>
          + <group ref="tns:ConstValue" />
          + </complexType>
          + </element>
          + <element name="annotation" type="tns:Annotation"
          + minOccurs="0" maxOccurs="unbounded" />
          + </sequence>
          + <attribute name="field-id" type="long" />
          + <attribute name="name" type="string" use="required" />
          + <attribute name="required" type="tns:Requiredness" />
          + <attribute name="doc" type="string" />
          + </extension>
          + </complexContent>
          + </complexType>
          +
          + <simpleType name="Requiredness">
          + <restriction base="string">
          + <enumeration value="required" />
          + <enumeration value="optional" />
          + </restriction>
          — End diff –

          Ok, I did not read it correctly. The attribute is of course optional by default, and that's perfectly fine.

          githubbot ASF GitHub Bot added a comment - Github user Jens-G commented on a diff in the pull request: https://github.com/apache/thrift/pull/774#discussion_r49244531 — Diff: lib/xml/thrift-idl.xsd — @@ -0,0 +1,265 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://thrift.apache.org/xml/idl" + xmlns:tns="http://thrift.apache.org/xml/idl" + elementFormDefault="qualified"> + + <element name="idl" type="tns:IDL" /> + <element name="document" type="tns:Document" /> + + <complexType name="IDL"> + <sequence> + <element ref="tns:document" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="Document"> + <sequence> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="include" type="tns:Include" /> + <element name="namespace" type="tns:Namespace" /> + </choice> + <choice minOccurs="0" maxOccurs="unbounded"> + <element name="exception" type="tns:Exception" /> + <element name="typedef" type="tns:Typedef" /> + <element name="service" type="tns:Service" /> + <element name="struct" type="tns:Struct" /> + <element name="const" type="tns:Const" /> + <element name="union" type="tns:Union" /> + <element name="enum" type="tns:Enum" /> + </choice> + </sequence> + <attribute name="name" type="string" /> + <attribute name="targetNamespace" type="anyURI" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Include"> + <attribute name="file" type="string" /> + <attribute name="name" type="string" /> + </complexType> + + <complexType name="Namespace"> + <sequence> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" /> + <attribute name="value" type="string" /> + <attribute name="doc" type="string" /> + </complexType> + + <group name="AbstractStruct"> + <sequence> + <element name="field" type="tns:Field" + minOccurs="0" maxOccurs="unbounded" /> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </group> + + <attributeGroup name="StructAttributes"> + <attribute name="name" type="string" /> + <attribute name="doc" type="string" /> + </attributeGroup> + + <complexType name="Exception"> + <group ref="tns:AbstractStruct" /> + <attributeGroup ref="tns:StructAttributes" /> + </complexType> + + <complexType name="Service"> + <sequence> + <element name="method" type="tns:Method" + minOccurs="0" maxOccurs="unbounded" /> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="targetNamespace" type="string" use="required" /> + <attribute name="parent-module" type="string" use="optional" /> + <attribute name="parent-id" type="string" use="optional" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Method"> + <sequence> + <element name="returns" type="tns:ThriftType" /> + <element name="arg" type="tns:Field" + minOccurs="0" maxOccurs="unbounded" /> + <element name="throws" type="tns:Field" + minOccurs="0" maxOccurs="unbounded" /> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="oneway" type="boolean" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Typedef"> + <complexContent> + <extension base="tns:ThriftType"> + <sequence> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="doc" type="string" /> + </extension> + </complexContent> + </complexType> + + <complexType name="Struct"> + <group ref="tns:AbstractStruct" /> + <attributeGroup ref="tns:StructAttributes" /> + </complexType> + + <complexType name="Union"> + <group ref="tns:AbstractStruct" /> + <attributeGroup ref="tns:StructAttributes" /> + </complexType> + + <complexType name="Enum"> + <sequence> + <element name="member" minOccurs="1" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="value" type="int" /> + <attribute name="explicit" type="boolean" /> + <attribute name="doc" type="string" /> + </complexType> + </element> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="name" type="string" use="required" /> + <attribute name="doc" type="string" /> + </complexType> + + <complexType name="Field"> + <complexContent> + <extension base="tns:ThriftType"> + <sequence> + <element name="default" minOccurs="0" maxOccurs="1"> + <complexType> + <group ref="tns:ConstValue" /> + </complexType> + </element> + <element name="annotation" type="tns:Annotation" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="field-id" type="long" /> + <attribute name="name" type="string" use="required" /> + <attribute name="required" type="tns:Requiredness" /> + <attribute name="doc" type="string" /> + </extension> + </complexContent> + </complexType> + + <simpleType name="Requiredness"> + <restriction base="string"> + <enumeration value="required" /> + <enumeration value="optional" /> + </restriction> — End diff – Ok, I did not read it correctly. The attribute is of course optional by default, and that's perfectly fine.
          jensg Jens Geyer added a comment -

          I am right now testing it in my Github branch, already made some minor changes.

          I have prototyped transforms that can create valid XML schema and WSDL files from Thrift IDL, as well as transform SOAP requests and responses to and from Thrift messages. Those transforms are not included because they may be outside the scope of Thrift, but I can provide them if interested. Regardless, I feel the XML model is generally useful and might be a good addition to the Thrift compiler.

          That stuff could fit into the contrib folder.

          However, it also somewhat overlaps with the existing XSD generator. How would you describe the relationship between those two?

          jensg Jens Geyer added a comment - I am right now testing it in my Github branch, already made some minor changes. I have prototyped transforms that can create valid XML schema and WSDL files from Thrift IDL, as well as transform SOAP requests and responses to and from Thrift messages. Those transforms are not included because they may be outside the scope of Thrift, but I can provide them if interested. Regardless, I feel the XML model is generally useful and might be a good addition to the Thrift compiler. That stuff could fit into the contrib folder. However, it also somewhat overlaps with the existing XSD generator. How would you describe the relationship between those two?
          bcg Benjamin Gould added a comment -

          > That stuff could fit into the contrib folder.

          > However, it also somewhat overlaps with the existing XSD generator. How would you describe the relationship between those two?

          Unfortunately the XSD generator doesn't actually produce a valid XML schema in many cases... IIRC it doesn't really handle container types properly etc. Also it generates some weird PHP include files which don't have a clear purpose. I just assumed that the whole generator is some old code that has|had some usefulness at Facebook and is not really for general use.

          I don't think my solution is necessarily a good replacement though (at least from a Thrift compiler perspective) because it depends on having a XSLT library available to transform the output of this XML generator... that would introduce a dependency to the compiler, and it is something that can easily be done by application code. It makes sense to me that those transforms could go into the contrib folder, or in the lib/xml folder. In any case, while my solution is working well enough that I can import the WSDLs into soapUI and use it as a test client for my Thrift services, the transforms are still "alpha" and need some polishing up, and I still need to implement some corner cases like parent services etc. When they are further along I can open up a new JIRA ticket.

          bcg Benjamin Gould added a comment - > That stuff could fit into the contrib folder. > However, it also somewhat overlaps with the existing XSD generator. How would you describe the relationship between those two? Unfortunately the XSD generator doesn't actually produce a valid XML schema in many cases... IIRC it doesn't really handle container types properly etc. Also it generates some weird PHP include files which don't have a clear purpose. I just assumed that the whole generator is some old code that has|had some usefulness at Facebook and is not really for general use. I don't think my solution is necessarily a good replacement though (at least from a Thrift compiler perspective) because it depends on having a XSLT library available to transform the output of this XML generator... that would introduce a dependency to the compiler, and it is something that can easily be done by application code. It makes sense to me that those transforms could go into the contrib folder, or in the lib/xml folder. In any case, while my solution is working well enough that I can import the WSDLs into soapUI and use it as a test client for my Thrift services, the transforms are still "alpha" and need some polishing up, and I still need to implement some corner cases like parent services etc. When they are further along I can open up a new JIRA ticket.
          jensg Jens Geyer added a comment -

          Is there any way to generate valid XSD from the new XML output? I just looked for the latest XSD changes from last year and I found that it was you as well: THRIFT-3417. Does that mean that you stopped using the XSD generator in favour of the new XML generator?

          jensg Jens Geyer added a comment - Is there any way to generate valid XSD from the new XML output? I just looked for the latest XSD changes from last year and I found that it was you as well: THRIFT-3417 . Does that mean that you stopped using the XSD generator in favour of the new XML generator?
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/thrift/pull/774

          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/thrift/pull/774
          jensg Jens Geyer added a comment -

          Committed.

          jensg Jens Geyer added a comment - Committed.
          bcg Benjamin Gould added a comment -

          Hi Jens, thanks for committing. To answer your question, I've not been using the XSD generator, I've been creating XSD from the new XML generator by using an XSL transform.

          I'm attaching a zip with the transforms that might be more illustrative of what I mean. The output of the transforms is in the gen-xml/ folder of the zip file. The transforms themselves and the commands to run them are in the top level folder. There are known issues such as not properly handling parent services and not really respecting "requiredness" properly. However it should give you an idea of where I am going with it.

          bcg Benjamin Gould added a comment - Hi Jens, thanks for committing. To answer your question, I've not been using the XSD generator, I've been creating XSD from the new XML generator by using an XSL transform. I'm attaching a zip with the transforms that might be more illustrative of what I mean. The output of the transforms is in the gen-xml/ folder of the zip file. The transforms themselves and the commands to run them are in the top level folder. There are known issues such as not properly handling parent services and not really respecting "requiredness" properly. However it should give you an idea of where I am going with it.

          People

            bcg Benjamin Gould
            bcg Benjamin Gould
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: