0

我知道如何为标签中的简单实体定义 xml 模式。我们如何为带有参数的标签定义 xml 架构?

<logins>
<login type="uname" value="robert"/>
<login type="name"  value="robert williams" />
</login>

我知道

<?xml version="1.0" encoding="UTF-8"?>
  <xs:schema>
    <xs: element name="login">
  <xs:complexType>
  <xs:sequence>

         <!-- What will come here ??-->
       </xs:sequence>
       </xs:complexType>
      </xs:element>
    </xs:schema>
4

1 回答 1

2
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XMLSchema1"
    elementFormDefault="qualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:complexType name ="loginType">
    <xs:attribute name ="name" type ="xs:string" use="required"/>
    <xs:attribute name ="value" type ="xs:string" use="required"/>
  </xs:complexType>

  <xs:complexType name ="loginsType">
    <xs:sequence>
      <xs:sequence>
        <xs:element name="login" type ="loginType" minOccurs ="1" maxOccurs ="unbounded" />
      </xs:sequence>
    </xs:sequence>
  </xs:complexType>

  <xs:element name ="logins" type ="loginsType"/>
</xs:schema>
于 2013-05-29T12:50:58.277 回答