2010-11-14 66 views
0
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"/>** - 我將使用此聲明。但是,我在哪裏使用發生。它只能用元素來完成?對嗎?XML模式疑問!

+0

的問題是不明確的。 – khachik 2010-11-14 17:26:17

回答

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>