2010-11-14 64 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>