日期:2010-08-10  浏览次数:20364 次

以下是描述上面结构的schema片断:  

<element  name="book"  type="tns:book"/>
<complexType  name="Book">
<!--  Either  the  following  group  must  occur  or  else  the
href  attribute  must  appear,  but  not  both.  -->
<sequence  minOccurs="0"  maxOccurs="1">
<element  name="title"  type="xsd:string"/>
<element  name="firstauthor"  type="tns:Person"/>
<element  name="secondauthor"  type="tns:Person"/>
</sequence>
<attribute  name="href"  type="uriReference"/>
<attribute  name="id"  type="ID"/>
<anyAttribute  namespace="##other"/>
</complexType>
<element  name="Person"  base="tns:Person"/>
<complexType  name="Person">
<!--  Either  the  following  group  must  occur  or  else  the
href  attribute  must  appear,  but  not  both.  -->
<sequence  minOccurs="0"  maxOccurs="1">
<element  name="name"  type="xsd:string"/>
<element  name="address"  type="tns:Address"/>
</sequence>
<attribute  name="href"  type="uriReference"/>
<attribute  name="id"  type="ID"/>
<anyAttribute  namespace="##other"/>
</complexType>
<element  name="Address"  base="tns:Address"/>
<complexType  name="Address">
<!--  Either  the  following  group  must  occur  or  else  the
href  attribute  must  appear,  but  not  both.  -->
<sequence  minOccurs="0"  maxOccurs="1">
<element  name="street"  type="xsd:string"/>
<element  name="city"  type="xsd:string"/>
<element  name="state"  type="xsd:string"/>
</sequence>
<attribute  name="href"  type="uriReference"/>
<attribute  name="id"  type="ID"/>
<anyAttribute  namespace="##other"/>
</complexType>  

5.4.2  数组
SOAP数组定义为具有"SOAP-ENC:Array"类型或一个从"SOAP-ENC:Array"衍生的类型(参见规则8)。数组表示为元素值,对元素的名没有特别的约束(正如元素值并不约束它们所属的元素)。数组可以包含任意类型的元素,包括嵌套数组。可以创建新的类型(受SOAP-ENC:Array
类型限制)来表示数组,如整数数组或某些用户定义的枚举。数组值表示为组成这个数组的项的元素的规则序列。在数组值中,元素名对于区分accesor并不重要。元素可以有任意的名。实际上,元素常常用它们在schema中暗示或确定的数组类型来命名元素。并且一般情况下对于复合值来说,如果数组中数组项的值是single-reference值,则这个数组项包含它的值,否则,该数组项通过"href"属性引用这个值。下面的例子是一个整型数组的schema片断:  

<element  name="myfavoritenumbers"
type="SOAP-ENC:Array"/>
<myFavoriteNumbers
SOAP-ENC:arrayType="xsd:int[2]">
<number>3</number>
<number>4</number>
</myFavoriteNumbers>  

在这个例子中,数组"myfavoritenumbers"包括几个成员,每个成员是一个类型为soap-enc:int的值。注意soap-enc:array允许不受限制的元素名,它们不传达任何类型信息,所以在使用时,或者它们有xsi:type属性,或者它们所属的元素有soap-enc:arraytype属性。自然,由soap-enc:array衍生的类型可以声明局部元素,但这种情况下要包括类型信息。上面已经提到,soap-enc  schema包含了元素的声明,元素名与"xml  schema  part  2:  datatypes"规范[11]中的简单类型一致。其中包括了对"array"的声明。于是,我们可以这样写:  

<soap-enc:array  soap-enc:arraytype="xsd:int[2]">