当我尝试针对xsd验证xml时,我遇到“无法找到元素声明”错误。 我粘贴在xml和xsd的前几行之后。
XML:
<?xml version="1.0" encoding="UTF-8"?>
<VMxRqDef targetNamespace="http://firstdatacorp.com/framework/core/vmx/MsgIn"
xmlns="http://firstdatacorp.com/framework/core/vmx/MsgIn"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
<VMX_ROOT>
XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://firstdatacorp.com/framework/core/vmx/MsgIn" xmlns="http://firstdatacorp.com/framework/core/vmx/MsgIn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="VMxRqDef">
<xs:sequence>
<xs:element name="VMX_ROOT">
请你帮我解决这个问题。
答案 0 :(得分:0)
您尚未在Xml架构中定义根元素,只是类型。您可能希望您的架构使用您当前分配给复杂类型的名称定义元素:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://firstdatacorp.com/framework/core/vmx/MsgIn" xmlns="http://firstdatacorp.com/framework/core/vmx/MsgIn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="VMxRqDef">
<xs:complexType>
<xs:sequence>
<xs:element name="VMX_ROOT">
...然后根据需要添加结束标记来完成层次结构。
如果你真的想给复杂类型命名(所以它也可以在其他元素中使用),你也可以这样做:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://firstdatacorp.com/framework/core/vmx/MsgIn" xmlns="http://firstdatacorp.com/framework/core/vmx/MsgIn" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="VMxRqDef" type="VMxRqDefType"/>
<xs:complexType name="VMxRqDefType">
<xs:sequence>
<xs:element name="VMX_ROOT">