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

Arrays and XSD

Expand Messages
  • Rich Salz
    Can repeating elements -- i.e., arrays -- appear with other elements, or must they be they only element inside a container ? The question is about how folks
    Message 1 of 6 , Jun 1, 2001
    • 0 Attachment
      Can repeating elements -- i.e., arrays -- appear with other elements, or
      must they be they only element inside a "container"? The question is
      about how folks would, or could, or must, write the schema.

      For example a C structure that has a two strings and a list of integers
      might be:
      struct st1 { char* s1; char* s2; int count; int ia[10]; };
      or it might be
      struct st1 { char* s1; char* s2; int count; int* ia; }

      Either way, they would be serialized as:
      <tns:st1>
      <s1>mystring</s1>
      <s2>hello</s2>
      <count>1</count>
      <ia SOAP-ENC:arrayType="xsd:int">
      <x>1</x><x>2</x>
      </ia>
      </tns:st1>

      So, how do you write the schema for that?

      It *seems* like a quality of implementation issue:
      <complexType name="tns:st1Type">
      <element name="tns:s1" type="string"/>
      <element name="tns:s2" type="string"/>
      <element name="tns:count" type="integer"/>
      <element name="tns:ia" type="integer" maxOccurs="10"
      minOccurs="0"/>
      </complexType>

      Or create an intermediate holder:
      <complexType name="tns:ia">
      <element name="tns:i" type="integer" minOccurs="0"
      maxOccurs="10"/>
      </complexType>

      (Please excuse the XSD syntax errors I'm sure I left in. :)

      /r$
    • Rich Salz
      ... The question is do I HAVE to do it that way. I know I can, and I know that works, but is the first schema fragment I showed legal for SOAP serialization?
      Message 2 of 6 , Jun 1, 2001
      • 0 Attachment
        > Isn't something like this what you need?:
        ...
        > Or do I misunderstand the question?

        The question is do I HAVE to do it that way.
        I know I can, and I know that works, but is the first schema fragment I
        showed "legal" for SOAP serialization?
        /r$
      • Bob Cunnings
        Hi, Isn t something like this what you need?:
        Message 3 of 6 , Jun 1, 2001
        • 0 Attachment
          Hi,

          Isn't something like this what you need?:

          <schema targetNamespace="foo" xmlns:tns="foo"
          xmlns="http://www.w3.org/2001/10/XMLSchema"
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

          <complexType name="ArrayOfInt">
          <complexContent>
          <sequence>
          <element name="item" type="string" minOccurs="0"
          maxOccurs="unbounded"/>
          </sequence>
          </complexContent>
          </complexType>

          <complexType name="st1Type">
          <element name="s1" type="string"/>
          <element name="s2" type="string"/>
          <element name="count" type="integer"/>
          <element name="ia" type="tns:ArrayOfInt"/>
          </complexType>
          </schema>

          Or do I misunderstand the question?

          RC

          > Can repeating elements -- i.e., arrays -- appear with other elements, or
          > must they be they only element inside a "container"? The question is
          > about how folks would, or could, or must, write the schema.
          >
          > For example a C structure that has a two strings and a list of integers
          > might be:
          > struct st1 { char* s1; char* s2; int count; int ia[10]; };
          > or it might be
          > struct st1 { char* s1; char* s2; int count; int* ia; }
          >
          > Either way, they would be serialized as:
          > <tns:st1>
          > <s1>mystring</s1>
          > <s2>hello</s2>
          > <count>1</count>
          > <ia SOAP-ENC:arrayType="xsd:int">
          > <x>1</x><x>2</x>
          > </ia>
          > </tns:st1>
          >
          > So, how do you write the schema for that?
          >
          > It *seems* like a quality of implementation issue:
          > <complexType name="tns:st1Type">
          > <element name="tns:s1" type="string"/>
          > <element name="tns:s2" type="string"/>
          > <element name="tns:count" type="integer"/>
          > <element name="tns:ia" type="integer" maxOccurs="10"
          > minOccurs="0"/>
          > </complexType>
          >
          > Or create an intermediate holder:
          > <complexType name="tns:ia">
          > <element name="tns:i" type="integer" minOccurs="0"
          > maxOccurs="10"/>
          > </complexType>
          >
          > (Please excuse the XSD syntax errors I'm sure I left in. :)
          >
          > /r$
          >
          > 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/
          >
        • Martin Gudgin
          The XML structure of your struct st1, per SOAP section 5 would be; mystring hello 1
          Message 4 of 6 , Jun 1, 2001
          • 0 Attachment
            The XML structure of your struct st1, per SOAP section 5 would be;

            <p:st1 xmlns:p='urn:example-org:someuri' >
            <s1>mystring</s1>
            <s2>hello</s2>
            <count>1</count>
            <ia xmlns:enc='http://schemas.xmlsoap.org/soap/encoding/"
            xmlns:xsd='http://www.w3.org/2001/XMLSchema'
            enc:arrayType='xsd:int[2]' >
            <x>1</x>
            <x>2</x>
            </ia>
            </p:st1>

            and the corresponding schema definition would be;

            <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
            xmlns:enc='http://schemas.xmlsoap.org/soap/encoding/'
            xmlns:this='urn:example-org:someuri'
            targetNamespace='urn:example-org:someuri' >

            <xs:import namespace='http://schemas.xmlsoap.org/soap/encoding/" />

            <xs:element name='st1' type='this:st1Type' />
            <xs:complexType name='st1Type' >
            <xs:sequence>
            <xs:element name='s1' type='xsd:string' />
            <xs:element name='s2' type='xsd:string' />
            <xs:element name='count' type='xsd:int' />
            <xs:element name='ia' type='enc:Array' />
            </xs:sequence>
            </xs:complexType>

            </xs:schema>

            SOAP section 5 states that arrays are serialized as instances of the type
            Array in the http://schemas.xmlsoap.org/soap/encoding/ namespace.

            If you wanted to be more specific you could derive a type for an array of
            between zero and ten ints;

            <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
            xmlns:enc='http://schemas.xmlsoap.org/soap/encoding/'
            xmlns:this='urn:example-org:someuri'
            targetNamespace='urn:example-org:someuri' >

            <xs:import namespace='http://schemas.xmlsoap.org/soap/encoding/" />

            <xs:element name='st1' type='this:st1Type' />
            <xs:complexType name='st1Type' >
            <xs:sequence>
            <xs:element name='s1' type='xs:string' />
            <xs:element name='s2' type='xs:string' />
            <xs:element name='count' type='xs:int' />
            <xs:element name='ia' type='this:iaArrayOfIntType' />
            </xs:sequence>
            </xs:complexType>

            <xs:complexType name='iaArrayOfIntType' >
            <xs:complexContent>
            <xs:restriction base='enc:Array' >
            <xs:sequence>
            <xs:element name='x' type='xs:int' minOccurs='0' maxOccurs='10' />
            </xs:sequence>
            <xs:attributeGroup ref="enc:arrayAttributes" />
            <xs:attributeGroup ref="enc:commonAttributes" />
            </xs:restriction>
            </xs:complexContent>
            </xs:complexType>

            </xs:schema>

            but you are not required to do so.

            Hope this helps,

            Martin Gudgin
            DevelopMentor

            ----- Original Message -----
            From: "Rich Salz" <rsalz@...>
            To: <soapbuilders@yahoogroups.com>
            Sent: Friday, June 01, 2001 2:49 PM
            Subject: [soapbuilders] Arrays and XSD


            > Can repeating elements -- i.e., arrays -- appear with other elements, or
            > must they be they only element inside a "container"? The question is
            > about how folks would, or could, or must, write the schema.
            >
            > For example a C structure that has a two strings and a list of integers
            > might be:
            > struct st1 { char* s1; char* s2; int count; int ia[10]; };
            > or it might be
            > struct st1 { char* s1; char* s2; int count; int* ia; }
            >
            > Either way, they would be serialized as:
            > <tns:st1>
            > <s1>mystring</s1>
            > <s2>hello</s2>
            > <count>1</count>
            > <ia SOAP-ENC:arrayType="xsd:int">
            > <x>1</x><x>2</x>
            > </ia>
            > </tns:st1>
            >
            > So, how do you write the schema for that?
            >
            > It *seems* like a quality of implementation issue:
            > <complexType name="tns:st1Type">
            > <element name="tns:s1" type="string"/>
            > <element name="tns:s2" type="string"/>
            > <element name="tns:count" type="integer"/>
            > <element name="tns:ia" type="integer" maxOccurs="10"
            > minOccurs="0"/>
            > </complexType>
            >
            > Or create an intermediate holder:
            > <complexType name="tns:ia">
            > <element name="tns:i" type="integer" minOccurs="0"
            > maxOccurs="10"/>
            > </complexType>
            >
            > (Please excuse the XSD syntax errors I'm sure I left in. :)
            >
            > /r$
            >
            > 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/
            >
            >
          • Rich Salz
            Well, that s sort of reverse logic. You took an encoding and derived a schema. I m instead asking about the schemas and can be encoded. This thread is also
            Message 5 of 6 , Jun 1, 2001
            • 0 Attachment
              Well, that's sort of reverse logic. You took an encoding and derived a
              schema. I'm instead asking about the schemas and can be encoded.

              This thread is also going on W3C XP list, so I'll continue there.
              /r$
            • Martin Gudgin
              Err, I don t think I did. I took section 5 and wrote a schema based on that... Gudge ... From: Rich Salz To:
              Message 6 of 6 , Jun 2, 2001
              • 0 Attachment
                Err, I don't think I did. I took section 5 and wrote a schema based on
                that...

                Gudge

                ----- Original Message -----
                From: "Rich Salz" <rsalz@...>
                To: <soapbuilders@yahoogroups.com>
                Sent: Saturday, June 02, 2001 2:05 AM
                Subject: Re: [soapbuilders] Arrays and XSD


                > Well, that's sort of reverse logic. You took an encoding and derived a
                > schema. I'm instead asking about the schemas and can be encoded.
                >
                > This thread is also going on W3C XP list, so I'll continue there.
                > /r$
                >
                > 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/
                >
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.