Loading ...
Sorry, an error occurred while loading the content.

Re: [soapbuilders] Schema question

Expand Messages
  • Martin Gudgin
    No, for the same reason. The effective type definition for address is;
    Message 1 of 23 , Apr 3, 2002
    • 0 Attachment
      No, for the same reason. The effective type definition for address is;

      <complexType name="address">
      <sequence>
      <element name="city" type="xsd:string"/>
      <element name="zip" type="xsd:string"/>
      <element name="country" type="xsd:string"/>
      <element name="zip" type="xsd:integer"/>
      </sequence>
      </complexType>

      Martin


      ----- Original Message -----
      From: "Robert van Engelen" <engelen@...>
      To: <soapbuilders@yahoogroups.com>
      Sent: Wednesday, April 03, 2002 7:27 PM
      Subject: Re: [soapbuilders] Schema question


      >
      > Thanks!
      >
      > It is easy to overlook this kind of information in these long specs.
      >
      > One more question though: is the following legal?
      >
      > <complexType name="baseAddress">
      > <sequence>
      > <element name="city" type="xsd:string"/>
      > <element name="zip" type="xsd:string"/>
      > <element name="country" type="xsd:string"/>
      > </sequence>
      > </complexType>
      >
      > <complexType name="address">
      > <complexContent>
      > <extension base="tns:baseAddress">
      > <sequence>
      > <element name="zip" type="xsd:integer"/>
      > </sequence>
      > </extension>
      > </complexContent>
      > </complexType>
      >
      > If this is legal, is the resulting XML allowed to carry two zip elements
      or
      > only one?
      >
      > I am asking this because:
      >
      > 1. gSOAP supports single inheritance. When communicating derived class
      > instances over SOAP also the base class members need to be present in the
      > SOAP message (just like any OO implementation keeps base class information
      > in the derived class instances).
      >
      > 2. The problem is that if schemas/WSDL disallows the above then SOAP is
      not
      > suitable for OO! (or maybe it need to be accomplished with some tricks).
      >
      > - Robert
      >
      >
      > -----------------------------------------------------------------
      > This group is a forum for builders of SOAP implementations to discuss
      implementation and interoperability issues. Please stay on-topic.
      >
      > To unsubscribe from this group, send an email to:
      > soapbuilders-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
    • Rosimildo daSIlva
      ... I agree. The programming languages are what they are. C#, Java, C++ and others have the constructs to build Classes, Inheritance, Polymorphism, etc.These
      Message 2 of 23 , Apr 3, 2002
      • 0 Attachment
        >
        > How do C# or Java come into the picture? I though
        > you were
        > discussing the limitations of XML Schema... not C#
        >

        I agree. The programming languages are what they are.
        C#, Java, C++
        and others have the constructs to build Classes,
        Inheritance, Polymorphism, etc.These mechanisms are
        very powerful.

        At the same time, I understand where Robert is
        coming from.

        As has been debated before, XML-Schema and in some
        extent SOAP/WSDL, are
        very limited regarding modeling of systems using
        techniques sich as Object
        Orientation. The Schema limits you on how you define
        "Messages" to be delivered
        back and forth, and WSDL is very weak regarding
        composition of end-points.

        Assuming that one "portType", defines one interface.
        It would be nice
        to compose more complex interfaces ( portTypes ) using
        inheritance:

        interface SuperTV extends PublicTV, CableTV, DishTV
        {


        };

        where: PublicTV --- described by public_tv.wsdl,
        CableTV --- described by cable_tv.wsdl,
        DiskTV --- described by dish_tv.wsdl

        Now this service, super_tv.wsdl is higher level
        service that using composition
        provide a more sophisticated service that wants
        simplicity for a fee. <g>

        This is very basic, and still missing in WSDL/SOAP.
        Imagine things
        like Security, Session Managment, QoS, etc.

        Rosimildo.



        __________________________________________________
        Do You Yahoo!?
        Yahoo! Tax Center - online filing with TurboTax
        http://taxes.yahoo.com/
      • david_cleary
        ... Since I haven t seen a reply that tells you how to code this, here it goes. Use a union type. Here is the syntax using an anonyomous type decl and requires
        Message 3 of 23 , Apr 4, 2002
        • 0 Attachment
          --- In soapbuilders@y..., Robert van Engelen <engelen@a...> wrote:
          >
          > Hi,
          >
          > I have a question with regard to the validity of the following
          schema:
          >
          > <complexType name="address">
          > <sequence>
          > <element name="city" type="xsd:string"/>
          > <element name="zip" type="xsd:string"/>
          > <element name="zip" type="xsd:integer"/>
          > <element name="country" type="xsd:string"/>
          > </sequence>
          > </complexType>

          Since I haven't seen a reply that tells you how to code this, here it
          goes. Use a union type. Here is the syntax using an anonyomous type
          decl and requires both to be present.

          <xs:element name="zip" minOccurs="2" maxOccurs="2">
          <xs:simpleType>
          <xs:union memberTypes="xs:int xs:string"/>
          </xs:simpleType>
          </xs:element>

          You need to use xsi:type in the instance if the datatype can't be
          determined by the data.

          David Cleary
          Progress Software
        • Noah Mendelsohn/Cambridge/IBM
          ... No, but the reason is either subtle (or pretty) as you prefer. Gudge has already pointed out that [1]: When two or more particles contained directly or
          Message 4 of 23 , Apr 4, 2002
          • 0 Attachment
            Rob van Engelen asks:

            >> One more question though: is the following legal?

            >> <complexType name="baseAddress">
            >> <sequence>
            >> <element name="city" type="xsd:string"/>
            >> <element name="zip" type="xsd:string"/>
            >> <element name="country" type="xsd:string"/>
            >> </sequence>
            >> </complexType>
            >>
            >> <complexType name="address">
            >> <complexContent>
            >> <extension base="tns:baseAddress">
            >> <sequence>
            >> <element name="zip" type="xsd:integer"/>
            >> </sequence>
            >> </extension>
            >> </complexContent>
            >> </complexType>

            No, but the reason is either subtle (or pretty) as you prefer. Gudge has
            already pointed out that [1]:

            'When two or more particles contained directly or indirectly in the
            {particles} of a model group have identically named element declarations
            as
            their {term}, the type definitions of those declarations must be the
            same.'

            If you read [2] you will find out that when <extension> is used in a
            schema document, the derived type has a {term} (essentially a particle)
            which is the net content model. In your case, a sequence of city,zip,
            country, zip (actually, I think it's
            sequence(sequence(city,zip,country),zip)). This model group violates the
            rule cited by Gudge. Hence, invalid.

            Actually, if you are a real schema guru, you will note that this only
            covers the common case in which you used the <schema> syntax to declare
            your schema. The general case is covered at [3], combined with [1]. It
            states:

            "[Definition:] For a particle (call it E, for extension) to be a valid
            extension of another particle (call it B, for base) one of the following
            must be true:
            1 They are the same particle.
            2 E's {min occurs}={max occurs}=1 and its {term} is a sequence group whose
            {particles}' first member is a particle all of whose properties,
            recursively, are identical to those of B, with the exception of
            {annotation} properties. "

            In other words, the constructs from the base type appear in the same
            particle of as the derived, and hence are subject to the rule cited by
            Gudge.

            In short, this example is clearly invalid, IMO at least.

            [1] http://www.w3.org/TR/xmlschema-1/#Model_Group_details
            [2] http://www.w3.org/TR/xmlschema-1/#declare-type
            [3] http://www.w3.org/TR/xmlschema-1/#cos-particle-extend

            ------------------------------------------------------------------
            Noah Mendelsohn Voice: 1-617-693-4036
            IBM Corporation Fax: 1-617-693-8676
            One Rogers Street
            Cambridge, MA 02142
            ------------------------------------------------------------------







            Robert van Engelen <engelen@...>
            04/03/02 01:27 PM
            Please respond to soapbuilders


            To: soapbuilders@yahoogroups.com
            cc: (bcc: Noah Mendelsohn/Cambridge/IBM)
            Subject: Re: [soapbuilders] Schema question


            Thanks!

            It is easy to overlook this kind of information in these long specs.

            One more question though: is the following legal?

            <complexType name="baseAddress">
            <sequence>
            <element name="city" type="xsd:string"/>
            <element name="zip" type="xsd:string"/>
            <element name="country" type="xsd:string"/>
            </sequence>
            </complexType>

            <complexType name="address">
            <complexContent>
            <extension base="tns:baseAddress">
            <sequence>
            <element name="zip" type="xsd:integer"/>
            </sequence>
            </extension>
            </complexContent>
            </complexType>

            If this is legal, is the resulting XML allowed to carry two zip elements
            or
            only one?

            I am asking this because:

            1. gSOAP supports single inheritance. When communicating derived class
            instances over SOAP also the base class members need to be present in the
            SOAP message (just like any OO implementation keeps base class information
            in the derived class instances).

            2. The problem is that if schemas/WSDL disallows the above then SOAP is
            not
            suitable for OO! (or maybe it need to be accomplished with some tricks).

            - Robert


            -----------------------------------------------------------------
            This group is a forum for builders of SOAP implementations to discuss
            implementation and interoperability issues. Please stay on-topic.

            To unsubscribe from this group, send an email to:
            soapbuilders-unsubscribe@yahoogroups.com



            Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          • Rosimildo daSIlva
            ... I am glad that there are people around here with that qualifications. Everytime I get close to the XML Schema spec, I feel sorry for myself, and I feel
            Message 5 of 23 , Apr 4, 2002
            • 0 Attachment
              <noah_mendelsohn@...> wrote:
              > Rob van Engelen asks:
              >
              > Actually, if you are a real schema guru, you will
              > note that this only
              > covers the common case in which you used the
              > <schema> syntax to declare
              > your schema. The general case is covered at [3],
              > combined with [1]. It
              > states:
              >

              I am glad that there are people around here with that
              qualifications. <g>

              Everytime I get close to the XML Schema spec, I feel
              sorry for myself, and I feel so "small" thinking to
              myself that I need the next 10 years to really
              understand it.

              Rosimildo.



              __________________________________________________
              Do You Yahoo!?
              Yahoo! Tax Center - online filing with TurboTax
              http://taxes.yahoo.com/
            • Robert van Engelen
              Noah, Thanks. Your comments are highly appreciated. Based on this I can conclude that the extension mechanism is not suitable to implement the usual OO base
              Message 6 of 23 , Apr 4, 2002
              • 0 Attachment
                Noah,

                Thanks. Your comments are highly appreciated.

                Based on this I can conclude that the extension mechanism is not suitable
                to implement the usual OO base class overriding semantics. Which means that
                a derived class (in the OO sense) must be represented with a schema
                that is separate from the base class schema. E.g. to represent the base
                class zip with the derived class zip I have to use a <union>. The unfortunate
                consequence is that the base class <-> derived class information is completely
                lost in the process and can't be retained in a WSDL document. One can argue
                that the OO hierarchies have nothing in common with XML schemas. However,
                since SOAP utilizes WSDL for declaring the necessary data types for RPC,
                the OO hierarchy may be exploited by SOAP-enabled applications that have to
                deal with object exchange. It appears that the two cannot be mixed, which is
                unfortunate for SOAP. For example, when I declare a remote procedure in WSDL
                with a parameter of a base type, then the procedure can never accept a derived
                type (with additional elements) because of validation violations. A solution
                is to write overloaded procedure definitions, one for each class. Is that a
                recommended solution?

                Question: Can <union> be used to refer to any schema type or only to primitive
                schema types?

                - Robert
              • graham glass
                hi robert, there is another way to look at this which i think is more useful. you *can* pass a derived schema type to a method which accepts a base schema type
                Message 7 of 23 , Apr 4, 2002
                • 0 Attachment
                  hi robert,
                   
                  there is another way to look at this which i think is more useful.
                   
                  you *can* pass a derived schema type to a method which accepts
                  a base schema type as long as the derived type doesn't contain
                  a field name which is a duplicate of the base name.
                   
                  i bet that 99% of the derived classes don't contain field names
                  that override those of their base classes, so this approach (with
                  a noted restriction) seems pragmatic.
                   
                  this is the kind of functionality that GLUE and many other SOAP
                  platforms support.
                   
                  cheers,
                  graham
                  -----Original Message-----
                  From: Robert van Engelen [mailto:engelen@...]
                  Sent: Thursday, April 04, 2002 4:31 PM
                  To: soapbuilders@yahoogroups.com
                  Subject: Re: [soapbuilders] Schema question


                  Noah,

                  Thanks. Your comments are highly appreciated.

                  Based on this I can conclude that the extension mechanism is not suitable
                  to implement the usual OO base class overriding semantics. Which means that
                  a derived class (in the OO sense) must be represented with a schema
                  that is separate from the base class schema. E.g. to represent the base
                  class zip with the derived class zip I have to use a <union>. The unfortunate
                  consequence is that the base class <-> derived class information is completely
                  lost in the process and can't be retained in a WSDL document. One can argue
                  that the OO hierarchies have nothing in common with XML schemas. However,
                  since SOAP utilizes WSDL for declaring the necessary data types for RPC,
                  the OO hierarchy may be exploited by SOAP-enabled applications that have to
                  deal with object exchange. It appears that the two cannot be mixed, which is
                  unfortunate for SOAP. For example, when I declare a remote procedure in WSDL
                  with a parameter of a base type, then the procedure can never accept a derived
                  type (with additional elements) because of validation violations. A solution
                  is to write overloaded procedure definitions, one for each class. Is that a
                  recommended solution?

                  Question: Can <union> be used to refer to any schema type or only to primitive
                  schema types?

                  - Robert


                  -----------------------------------------------------------------
                  This group is a forum for builders of SOAP implementations to discuss implementation and interoperability issues.  Please stay on-topic.

                  To unsubscribe from this group, send an email to:
                  soapbuilders-unsubscribe@yahoogroups.com



                  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
                • Noah Mendelsohn/Cambridge/IBM
                  Exactly the answer I would have given. Schema s type system is at best an 80/20 as a basis for representing this or that existing object system. First of all,
                  Message 8 of 23 , Apr 5, 2002
                  • 0 Attachment
                    Exactly the answer I would have given. Schema's type system is at best an
                    80/20 as a basis for representing this or that existing object system.
                    First of all, most programming languages emphasize inheritance of methods
                    rather than data (though there is no-doubt data inheritance going on as
                    well, but in many uses of OO only the methods are made public or protected
                    and are thus part of the overt interface contract.) Anyway, another
                    glaring hole is that schema makes no attempt at multiple inheritance (a
                    conscious keep it simple compromise.) Covering redefinition of a
                    like-named member property is probably below multiple-inheritance in terms
                    of the number of users who have screamed that they can't effectively
                    mapped to our system.

                    ------------------------------------------------------------------
                    Noah Mendelsohn Voice: 1-617-693-4036
                    IBM Corporation Fax: 1-617-693-8676
                    One Rogers Street
                    Cambridge, MA 02142
                    ------------------------------------------------------------------







                    "graham glass" <graham@...>
                    04/05/02 02:33 AM
                    Please respond to soapbuilders


                    To: <soapbuilders@yahoogroups.com>
                    cc: (bcc: Noah Mendelsohn/Cambridge/IBM)
                    Subject: RE: [soapbuilders] Schema question

                    hi robert,

                    there is another way to look at this which i think is more useful.

                    you *can* pass a derived schema type to a method which accepts
                    a base schema type as long as the derived type doesn't contain
                    a field name which is a duplicate of the base name.

                    i bet that 99% of the derived classes don't contain field names
                    that override those of their base classes, so this approach (with
                    a noted restriction) seems pragmatic.

                    this is the kind of functionality that GLUE and many other SOAP
                    platforms support.

                    cheers,
                    graham
                    -----Original Message-----
                    From: Robert van Engelen [mailto:engelen@...]
                    Sent: Thursday, April 04, 2002 4:31 PM
                    To: soapbuilders@yahoogroups.com
                    Subject: Re: [soapbuilders] Schema question


                    Noah,

                    Thanks. Your comments are highly appreciated.

                    Based on this I can conclude that the extension mechanism is not suitable
                    to implement the usual OO base class overriding semantics. Which means
                    that
                    a derived class (in the OO sense) must be represented with a schema
                    that is separate from the base class schema. E.g. to represent the base
                    class zip with the derived class zip I have to use a <union>. The
                    unfortunate
                    consequence is that the base class <-> derived class information is
                    completely
                    lost in the process and can't be retained in a WSDL document. One can
                    argue
                    that the OO hierarchies have nothing in common with XML schemas. However,
                    since SOAP utilizes WSDL for declaring the necessary data types for RPC,
                    the OO hierarchy may be exploited by SOAP-enabled applications that have
                    to
                    deal with object exchange. It appears that the two cannot be mixed, which
                    is
                    unfortunate for SOAP. For example, when I declare a remote procedure in
                    WSDL
                    with a parameter of a base type, then the procedure can never accept a
                    derived
                    type (with additional elements) because of validation violations. A
                    solution
                    is to write overloaded procedure definitions, one for each class. Is that
                    a
                    recommended solution?

                    Question: Can <union> be used to refer to any schema type or only to
                    primitive
                    schema types?

                    - Robert


                    -----------------------------------------------------------------
                    This group is a forum for builders of SOAP implementations to discuss
                    implementation and interoperability issues. Please stay on-topic.

                    To unsubscribe from this group, send an email to:
                    soapbuilders-unsubscribe@yahoogroups.com



                    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

                    Yahoo! Groups Sponsor

                    ADVERTISEMENT




                    -----------------------------------------------------------------
                    This group is a forum for builders of SOAP implementations to discuss
                    implementation and interoperability issues. Please stay on-topic.

                    To unsubscribe from this group, send an email to:
                    soapbuilders-unsubscribe@yahoogroups.com



                    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
                  • Robert van Engelen
                    Noah and Graham, Thanks! Please allow me to elaborate on this a little further for sake of clarity and usefulness to the SOAP interop community after which (I
                    Message 9 of 23 , Apr 5, 2002
                    • 0 Attachment
                      Noah and Graham,

                      Thanks!

                      Please allow me to elaborate on this a little further for sake of clarity
                      and usefulness to the SOAP interop community after which (I hope) this
                      issue can be closed.

                      gSOAP does support single inheritance and allows a derived class to be passed
                      to a method that accepts a base class.

                      However, to generate valid WSDL schemas for the 1% of code that does in fact
                      override base class fields needs some tweaking by renaming derived class fields
                      (in the language domain) to unique element names (in the schema domain).
                      I was just concerned that this renaming might break interoperability
                      between OO-based SOAP implementations (whatever that means) and I am very
                      interested to hear how other SOAP implementations handle this. [Note that gSOAP
                      has a fully automatic mapping from C/C++ data types to SOAP data types.]

                      As a general solution, a field 'F' of a derived class 'D' can be renamed to an
                      element '<D.F>' in case 'F' is a field in a base class. Any WSDL importer will
                      just use this (unique) element and doesn't need to be concerned about
                      overriding issues.

                      When gSOAP would import such as schema though, gSOAP could in fact declare a
                      derived class with field 'F' to recreate the (language-specific) OO hierarchy
                      with member overriding.

                      Interestingly enough, this approach allows for both OO implementations and
                      non-OO implementations to cope with schemas derived by extension. Maybe
                      I am reinventing the wheel here?

                      - Cheers, Robert
                    • Noah Mendelsohn/Cambridge/IBM
                      Thanks. I would have thought there were other potential member name issues. For example, if your programming language allows variable names to have
                      Message 10 of 23 , Apr 5, 2002
                      • 0 Attachment
                        Thanks. I would have thought there were other potential member name
                        issues. For example, if your programming language allows variable names
                        to have characters that are not XML Name characters. In general, I would
                        expect that for real interop of some particular inheritance model, someone
                        would have to write a specification saying: "here's how we map member
                        names that aren't legal XML names, here is how we rename members in the
                        1% of cases where a derived class does an incompatible override of a base,
                        etc."

                        ------------------------------------------------------------------
                        Noah Mendelsohn Voice: 1-617-693-4036
                        IBM Corporation Fax: 1-617-693-8676
                        One Rogers Street
                        Cambridge, MA 02142
                        ------------------------------------------------------------------







                        Robert van Engelen <engelen@...>
                        04/05/02 11:40 AM
                        Please respond to soapbuilders


                        To: soapbuilders@yahoogroups.com
                        cc: (bcc: Noah Mendelsohn/Cambridge/IBM)
                        Subject: Re: [soapbuilders] Schema question


                        Noah and Graham,

                        Thanks!

                        Please allow me to elaborate on this a little further for sake of clarity
                        and usefulness to the SOAP interop community after which (I hope) this
                        issue can be closed.

                        gSOAP does support single inheritance and allows a derived class to be
                        passed
                        to a method that accepts a base class.

                        However, to generate valid WSDL schemas for the 1% of code that does in
                        fact
                        override base class fields needs some tweaking by renaming derived class
                        fields
                        (in the language domain) to unique element names (in the schema domain).
                        I was just concerned that this renaming might break interoperability
                        between OO-based SOAP implementations (whatever that means) and I am very
                        interested to hear how other SOAP implementations handle this. [Note that
                        gSOAP
                        has a fully automatic mapping from C/C++ data types to SOAP data types.]

                        As a general solution, a field 'F' of a derived class 'D' can be renamed
                        to an
                        element '<D.F>' in case 'F' is a field in a base class. Any WSDL importer
                        will
                        just use this (unique) element and doesn't need to be concerned about
                        overriding issues.

                        When gSOAP would import such as schema though, gSOAP could in fact declare
                        a
                        derived class with field 'F' to recreate the (language-specific) OO
                        hierarchy
                        with member overriding.

                        Interestingly enough, this approach allows for both OO implementations and
                        non-OO implementations to cope with schemas derived by extension. Maybe
                        I am reinventing the wheel here?

                        - Cheers, Robert


                        -----------------------------------------------------------------
                        This group is a forum for builders of SOAP implementations to discuss
                        implementation and interoperability issues. Please stay on-topic.

                        To unsubscribe from this group, send an email to:
                        soapbuilders-unsubscribe@yahoogroups.com



                        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                      • Robert van Engelen
                        ... That s an accurate observation. I came up with conventions for special characters. For example, element maps to ns2__x_DOT_y_z, assuming that
                        Message 11 of 23 , Apr 8, 2002
                        • 0 Attachment
                          > Thanks. I would have thought there were other potential member name
                          > issues. For example, if your programming language allows variable names
                          > to have characters that are not XML Name characters. In general, I would

                          That's an accurate observation. I came up with conventions for special
                          characters. For example, element <ns1:x.y-z> maps to ns2__x_DOT_y_z,
                          assuming that ns1 refers to the same namespace URI as ns2 (light validation).

                          This way, I can map

                          class ns__X
                          { int n;
                          };
                          class ns__Y:ns__X
                          { int n;
                          int m;
                          };

                          to

                          <?xml version="1.0" encoding="UTF-8"?>
                          <schema
                          xmlns="http://www.w3.org/2001/XMLSchema"
                          xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                          xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                          targetNamespace="XXXXX"
                          xmlns:ns="XXXXX">
                          <complexType name="X">
                          <sequence>
                          <element name="n" type="xsd:int" minOccurs="0" maxOccurs="1"/>
                          </sequence>
                          </complexType>
                          <complexType name="Y">
                          <complexContent>
                          <extension base="ns:X">
                          <sequence>
                          <element name="ns:Y.n" type="xsd:int" minOccurs="0" maxOccurs="1"/>
                          <element name="m" type="xsd:int" minOccurs="0" maxOccurs="1"/>
                          </sequence>
                          </extension>
                          </complexContent>
                          </complexType>
                          </schema>

                          and vice-versa. I made a change to my schema generator to accomodate
                          overriding. Is the use of the element name="ns:Y.n" valid in this case?

                          - Robert
                        Your message has been successfully submitted and would be delivered to recipients shortly.