【发布时间】:2019-01-31 11:31:22
【问题描述】:
我在验证 xml 和 xsd 时遇到问题。我从 xsd 架构中收到此错误。
src-resolve.4.2:解析组件“urn:id”时出错。被发现了 'urn:id' 在命名空间中 'urn:schemas-microsoft-com:xml-diffgram-v1',但其中的组件 命名空间不可从架构文档中引用 '虚拟://服务器/schema.xsd'。如果这是不正确的命名空间, 也许'urn:id'的前缀需要改变。如果这是 正确的命名空间,然后应添加适当的“导入”标签 'virtual://server/schema.xsd'
在 xml 架构中我也发现了这个错误。
cvc-complex-type.2.4.d:发现无效内容以 元素“xs:模式”。此时不需要子元素。
这是我的 xml 文件
<?xml version="1.0" encoding="ISO-8859-1"?>
<AddCustomerNotesByExtIDResult>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Status">
<xs:complexType>
<xs:sequence>
<xs:element name="StatusCode" type="xs:int" minOccurs="0"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<NewDataSet>
<Status diffgr:id="Status1" msdata:rowOrder="0">
<StatusCode>0</StatusCode>
<Description>Customer Notes added successfully</Description>
</Status>
</NewDataSet>
</diffgr:diffgram>
</AddCustomerNotesByExtIDResult>
这是我的 xsd 文件
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="NewDataSet">
<xs:complexType>
<xs:sequence>
<xs:element name="Status">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:byte" name="StatusCode"/>
<xs:element type="xs:string" name="Description"/>
</xs:sequence>
<xs:attribute ref="urn:id" xmlns:urn="urn:schemas-microsoft-com:xml-diffgram-v1"/>
<xs:attribute ref="urn:rowOrder" xmlns:urn="urn:schemas-microsoft-com:xml-msdata"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AddCustomerNotesByExtIDResult">
<xs:complexType>
<xs:sequence>
<xs:element ref="xs:schema"/>
<xs:element ref="urn:diffgram" xmlns:urn="urn:schemas-microsoft-com:xml-diffgram-v1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
【问题讨论】: