XML schema Doubt!

假如想象 提交于 2019-12-24 21:06:56

问题


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. 

IF i consider these as attributes:<xs:attribute name="name" type="xs:string" use="required"/>** - i will use this statement. But then where do I make use of occurances. It can only be done with elements?Right?


回答1:


Since you want Name and Phone to appear in order, you must use elements, since the order of attributes in XML documents is (per the XML recommendation) not significant.

Your schema should look (in outline) something like:

<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>


来源:https://stackoverflow.com/questions/4177684/xml-schema-doubt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!