这就是我现在所拥有的
<main>
<col name="name1">test1</col>
<col name="name2">test2</col>
<col name="name3">test3</col>
<col name="name4">test4</col>
<col name="num1">true</col>
</main>
我想要上面的xsd,我试过
<xs:element name="main" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="col" minOccurs="0" maxOccurs="unbounded" >
<xs:attribute name="name1" type="xs:string" />
<xs:attribute name="name2" type="xs:string" />
<xs:attribute name="name2" type="xs:string" />
<xs:attribute name="num1" type="xs:boolean" />
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
这显示我错误。怎么能纠正这个?
答案 0 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="main">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="col">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>