Array Confusion

My confusion stems from some type definitions I've come across in WSDL
files, but I believe this is truly a question about XML-Schema and how types
work.

I've seen array types defined in two different ways:

Method 1:

      <s:complexType name="StringArray">
        <s:complexContent mixed="false">
          <s:restriction base="soapenc:Array">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="unbounded" name="String"
type="s:string"/>
            </s:sequence>
          </s:restriction>
        </s:complexContent>
      </s:complexType>

Method 2:

      <xs:complexType name="DoubleArray">
        <xs:complexContent>
          <xs:restriction base="soapenc:Array">
            <xs:sequence/>
            <xs:attribute ref="soapenc:arrayType" n1:arrayType="xs:double[]"
xmlns:n1="http://schemas.xmlsoap.org/wsdl/"/>
          </xs:restriction>
        </xs:complexContent>
      </xs:complexType>
    </xs:schema>

Method 1 makes perfect sense... given the following element declaration:

  <xs:element name="TestStrings">
    <xs:complexType>
    <xs:sequence>
      <xs:element name="Data" type="tns:StringArray"></xs:element>
    </xs:sequence>
    </xs:complexType>
  </xs:element>

This document is valid (at least, it's valid in XMLSpy :):

<TestStrings>
  <Data>
    <String>abc</String>
    <String>xyz</String>
  </Data>
</TestStrings>


However, method 2 has me baffled... given the following element declaration:

  <xs:element name="TestDoubles">
    <xs:complexType>
    <xs:sequence>
      <xs:element name="Data" type="tns:DoubleArray"></xs:element>
    </xs:sequence>
    </xs:complexType>
  </xs:element>

I haven't been able to come up with a valid document.  The Data element
isn't allowed to have text, but the sequence on DoubleArray is empty and
doesn't allow child elements.  What am I missing?

Brenda Bell
Sr. Software Architect
Juice Software, Inc.
Phone: 603.428.3994
Cell:  603.494.8206
Fax:   603.428.8713
Email: bbell@juicesoftware.com
MSN:   bbell@theotherbell.com

Received on Wednesday, 17 July 2002 12:45:13 UTC