【发布时间】:2012-03-12 21:47:50
【问题描述】:
我不是 XSD 专家。所以我使用 xsd.exe 快速生成一些我需要的 xsd,然后稍微调整它们(minOccur 等)。
但是现在它已经创建了两个 XSD 文件,一个是主要的,一个是额外的,它定义了一个复杂的类型。我怎么能把它们混在一起?我已经尝试了一段时间,但我不断收到编译错误。
这是他们的样子:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:app1="urn:ietf:params:xml:ns:xmpp-bind">
<xs:import namespace="urn:ietf:params:xml:ns:xmpp-bind" schemaLocation="Binding_app1.xsd" />
<xs:element name="iq">
<xs:complexType>
<xs:sequence>
<xs:element ref="app1:bind" />
</xs:sequence>
<xs:attribute name="id" type="xs:string" />
<xs:attribute name="type" type="xs:string" />
<xs:attribute name="to" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="iq" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
和
<?xml version="1.0" standalone="yes"?>
<xs:schema targetNamespace="urn:ietf:params:xml:ns:xmpp-bind" xmlns:mstns="urn:ietf:params:xml:ns:xmpp-bind" xmlns="urn:ietf:params:xml:ns:xmpp-bind" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:app1="urn:ietf:params:xml:ns:xmpp-bind">
<xs:element name="bind">
<xs:complexType>
<xs:sequence>
<xs:element name="resource" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
谢谢!
【问题讨论】:
-
当您 (a) 从主文件中删除
xs:import并且 (b) 仅将其替换为第二个文件中的元素声明(即仅完整的xs:element标记)时会发生什么? -
@JimGarrison 那么它不会在绑定元素中生成/验证 'xmlns="urn:ietf:params:xml:ns:xmpp-bind' 属性。