题
<?xml version="1.0"?>
<datatype xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:noNamespaceSchemaLocation="sampletype.xsd">
<table name="emp">
<columns>
<column>
<name>emp_id</name>
<data_type>int(200) </data_type>
</column>
</columns>
</table>
</datatype>
在这里,我为XML上述生成XSD,但这是不正确的。您能帮我生成XML的XSD吗?提前致谢。
解决方案
只需运行即可 xsd.exe
实用程序(请参阅: MSDN XML模式定义工具)通过此XML文件,您会得到答案:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="datatype" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="datatype" msdata:IsDataSet="true" msdata:Locale="en-US">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="table">
<xs:complexType>
<xs:sequence>
<xs:element name="columns" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="column" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0" />
<xs:element name="data_type" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
那是什么 不正确 关于这个XSD ??这 xsd.exe
试图猜测您的XML所包含的内容,但是在某些情况下,它只需要做出一些假设,因此由此产生的XSD可能或可能不是您所需要的,并且如果您有,则可以更有效地编写/更有效关于XML结构的其他知识。例如,如果你 知道 总会有一个 <table>
元素,您可以使事情变得容易得多。
不隶属于 StackOverflow