XML架构怀疑!

时间:2010-11-14 13:32:47

标签: xml xsd

Could any one tell me how to do this? i need to change it into **xml schema**. The problem that I am facing is that I can't think of where to use elements and wehere to use attributes. 

如果我将这些视为属性:<xs:attribute name="name" type="xs:string" use="required"/>** - 我将使用此声明。但那我在哪里可以利用出现。它只能用元素来完成吗?对吗?

1 个答案:

答案 0 :(得分:0)

由于您希望NamePhone按顺序出现,因此您必须使用元素,因为XML文档中的属性顺序(根据XML建议)并不重要。

您的架构应该(在概述中)看起来像:

<xs:element name="RetailerRequest">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="Name"
                  minOccurs="1"
                  maxOccurs="1"/>
      <xs:element ref="RetailerContact"
                  minOccurs="1"
                  maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:element name="RetailerContact">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="Name"
                  minOccurs="1"
                  maxOccurs="1"/>
      <xs:element name="Phone"
                  minOccurs="1"
                  maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
相关问题