验证 xml & xsd 失败
Validation xml & xsd fail
当使用架构验证 xml 并且我有 2 个架构时,验证错误
第 10 行:这里需要元素 'fault@http://www.BM.org/FCUBS/Schemas/FullAccountList' instead of 'fault@http://www.bea.com/wli/sb/context'
第 34 行:内容结束前的预期元素 'fault@http://www.BM.org/FCUBS/Schemas/FullAccountList'
<FulAccLstResponse_elm xmlns="http://www.BM.org/FCUBS/Schemas/FullAccountList">
<ResponseStatus>
<Code>444</Code>
<Description>Invalid Input Parameters</Description>
</ResponseStatus>
<ResponseData/>
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>382505</con:errorCode>
<con:reason>Validate action failed validation</con:reason>
<con:details>
<con1:ValidationFailureDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
<con1:message>validation error</con1:message>
<con1:xmlLocation>
<IDFlag>NAtT</IDFlag>
</con1:xmlLocation>
<con1:message>Expected elements 'NationalId@http://www.BM.org/FCUBS/Schemas/FullAccountList CustomerId@http://www.BM.org/FCUBS/Schemas/FullAccountList' before the end of the content in element FulAccLstRequest_elm@http://www.BM.org/FCUBS/Schemas/FullAccountList</con1:message>
<con1:xmlLocation>
<ful:FulAccLstRequest_elm xmlns:ns0="http://www.BM.org/FCUBS/Schemas/FullAccountList" xmlns:ful="http://www.BM.org/FCUBS/Schemas/FullAccountList">
<ful:CallingSystem>sys</ful:CallingSystem>
<ful:UserName>user1</ful:UserName>
<ful:Branch>100</ful:Branch>
<ful:IDFlag>NAtT</ful:IDFlag>
</ful:FulAccLstRequest_elm>
</con1:xmlLocation>
</con1:ValidationFailureDetail>
</con:details>
<con:location>
<con:node>RouteNode1</con:node>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>
</FulAccLstResponse_elm>
- 第一个架构(导入第二个架构)
<xsd:schema targetNamespace="http://www.BM.org/FCUBS/Schemas/FullAccountList" elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.BM.org/FCUBS/Schemas/FullAccountList"
xmlns:con="http://www.bea.com/wli/sb/context">
<xsd:import schemaLocation="Fault.xsd"
namespace="http://www.bea.com/wli/sb/context" />
<xsd:complexType name="FulAccLstRequest_cpx">
<xsd:sequence>
<xsd:element name="IDFlag">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="CUST"/>
<xsd:enumeration value="NAT"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:choice>
<xsd:element name="NationalId" type="xsd:string"/>
<xsd:element name="CustomerId" type="xsd:string"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstResponse_cpx">
<xsd:sequence>
<xsd:element name="ResponseStatus" type="FulAccLstResponseStatus_cpx"/>
<xsd:element name="ResponseData" type="FulAccLstResponseData_cpx"/>
<xsd:element name="fault" type="con:Fault_cpx" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstResponseStatus_cpx">
<xsd:sequence>
<xsd:element name="Code" type="xsd:string"/>
<xsd:element name="Description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstResponseData_cpx">
<xsd:sequence>
<xsd:element name="IFLEXAccountsStatus" type="xsd:string" default="0" minOccurs="0"/>
<xsd:element name="IFLEXAccounts" type="FulAccLstUBSAccounts_cpx" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstUBSAccounts_cpx">
<xsd:sequence>
<xsd:element name="Stvw-Account-Sumary-IO" type="QueryAccSumm-Query-IO-Type" minOccurs="0"/>
<xsd:element name="Stvw-Account-Sumary-Full" type="QueryAccSumm-Full-Type" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="QueryAccSumm-Full-Type">
<xsd:sequence>
<xsd:element name="CUST_NO" type="xsd:string" minOccurs="0"/>
<xsd:element name="Stvw-Account-Sumary--A" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CURRBAL" type="xsd:decimal" minOccurs="0"/>
<xsd:element name="CUSTACNO" type="xsd:string" minOccurs="0"/>
<xsd:element name="BRANCH_CODE" type="xsd:string" minOccurs="0"/>
<xsd:element name="CCY" type="xsd:string" minOccurs="0"/>
<xsd:element name="ACCOUNT_TYPE" type="xsd:string" minOccurs="0"/>
<xsd:element name="CUSTOMER_NAME" type="xsd:string" minOccurs="0"/>
<xsd:element name="AC_DESC" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="QueryAccSumm-Query-IO-Type">
<xsd:sequence>
<xsd:element name="CUST_NO" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="FulAccLstRequest_elm" type="FulAccLstRequest_cpx"/>
<xsd:element name="FulAccLstResponse_elm" type="FulAccLstResponse_cpx"/>
</xsd:schema>
第二个架构
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema targetNamespace="http://www.bea.com/wli/sb/context" xmlns="http://www.bea.com/wli/sb/context"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="fault" type="Fault_cpx"/>
<xsd:complexType mixed="true" name="Fault_cpx">
<xsd:sequence>
<xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute namespace="##any" processContents="lax"/>
</xsd:complexType>
</xsd:schema>
您混淆了 {http://www.bea.com/wli/sb/context}
命名空间中的全局定义元素 fault
,
使用本地定义的,在 {http://www.BM.org/FCUBS/Schemas/FullAccountList}
命名空间中。虽然,这两者
fault
s 看起来一样,它们只有本地名称相同。不然就是完全不同的元素了!
您的第二个(导入的)模式全局定义 fault
。之后,您可以仅通过引用在任何地方使用它。
但正如您在此处指定的那样:
<xsd:complexType name="FulAccLstResponse_cpx">
<xsd:sequence>
<xsd:element name="ResponseStatus" type="FulAccLstResponseStatus_cpx"/>
<xsd:element name="ResponseData" type="FulAccLstResponseData_cpx"/>
<xsd:element name="fault" type="con:Fault_cpx" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
FulAccLstResponse_cpx
类型中的 fault
是本地类型,因此属于架构的目标命名空间。
要使您的 XML 正常工作,您应该按如下方式定义该部分:
<xsd:complexType name="FulAccLstResponse_cpx">
<xsd:sequence>
<xsd:element name="ResponseStatus" type="FulAccLstResponseStatus_cpx"/>
<xsd:element name="ResponseData" type="FulAccLstResponseData_cpx"/>
<xsd:element ref="con:fault" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
P.S.
使用 XML 模式和 WSDL 的人可能会对以下链接感兴趣:
- 高性能通用 XML 带图表的架构文档生成器:http://www.flexdoc.xyz/flexdoc-xml/xsddoc/
- WSDL 和 XSD 相同:http://www.flexdoc.xyz/flexdoc-xml/wsdldoc/
如果您重视我对本网站的参与,请不要删除这些链接!
当使用架构验证 xml 并且我有 2 个架构时,验证错误
第 10 行:这里需要元素 'fault@http://www.BM.org/FCUBS/Schemas/FullAccountList' instead of 'fault@http://www.bea.com/wli/sb/context' 第 34 行:内容结束前的预期元素 'fault@http://www.BM.org/FCUBS/Schemas/FullAccountList'
<FulAccLstResponse_elm xmlns="http://www.BM.org/FCUBS/Schemas/FullAccountList">
<ResponseStatus>
<Code>444</Code>
<Description>Invalid Input Parameters</Description>
</ResponseStatus>
<ResponseData/>
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>382505</con:errorCode>
<con:reason>Validate action failed validation</con:reason>
<con:details>
<con1:ValidationFailureDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
<con1:message>validation error</con1:message>
<con1:xmlLocation>
<IDFlag>NAtT</IDFlag>
</con1:xmlLocation>
<con1:message>Expected elements 'NationalId@http://www.BM.org/FCUBS/Schemas/FullAccountList CustomerId@http://www.BM.org/FCUBS/Schemas/FullAccountList' before the end of the content in element FulAccLstRequest_elm@http://www.BM.org/FCUBS/Schemas/FullAccountList</con1:message>
<con1:xmlLocation>
<ful:FulAccLstRequest_elm xmlns:ns0="http://www.BM.org/FCUBS/Schemas/FullAccountList" xmlns:ful="http://www.BM.org/FCUBS/Schemas/FullAccountList">
<ful:CallingSystem>sys</ful:CallingSystem>
<ful:UserName>user1</ful:UserName>
<ful:Branch>100</ful:Branch>
<ful:IDFlag>NAtT</ful:IDFlag>
</ful:FulAccLstRequest_elm>
</con1:xmlLocation>
</con1:ValidationFailureDetail>
</con:details>
<con:location>
<con:node>RouteNode1</con:node>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>
</FulAccLstResponse_elm>
- 第一个架构(导入第二个架构)
<xsd:schema targetNamespace="http://www.BM.org/FCUBS/Schemas/FullAccountList" elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.BM.org/FCUBS/Schemas/FullAccountList"
xmlns:con="http://www.bea.com/wli/sb/context">
<xsd:import schemaLocation="Fault.xsd"
namespace="http://www.bea.com/wli/sb/context" />
<xsd:complexType name="FulAccLstRequest_cpx">
<xsd:sequence>
<xsd:element name="IDFlag">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="CUST"/>
<xsd:enumeration value="NAT"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:choice>
<xsd:element name="NationalId" type="xsd:string"/>
<xsd:element name="CustomerId" type="xsd:string"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstResponse_cpx">
<xsd:sequence>
<xsd:element name="ResponseStatus" type="FulAccLstResponseStatus_cpx"/>
<xsd:element name="ResponseData" type="FulAccLstResponseData_cpx"/>
<xsd:element name="fault" type="con:Fault_cpx" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstResponseStatus_cpx">
<xsd:sequence>
<xsd:element name="Code" type="xsd:string"/>
<xsd:element name="Description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstResponseData_cpx">
<xsd:sequence>
<xsd:element name="IFLEXAccountsStatus" type="xsd:string" default="0" minOccurs="0"/>
<xsd:element name="IFLEXAccounts" type="FulAccLstUBSAccounts_cpx" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FulAccLstUBSAccounts_cpx">
<xsd:sequence>
<xsd:element name="Stvw-Account-Sumary-IO" type="QueryAccSumm-Query-IO-Type" minOccurs="0"/>
<xsd:element name="Stvw-Account-Sumary-Full" type="QueryAccSumm-Full-Type" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="QueryAccSumm-Full-Type">
<xsd:sequence>
<xsd:element name="CUST_NO" type="xsd:string" minOccurs="0"/>
<xsd:element name="Stvw-Account-Sumary--A" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CURRBAL" type="xsd:decimal" minOccurs="0"/>
<xsd:element name="CUSTACNO" type="xsd:string" minOccurs="0"/>
<xsd:element name="BRANCH_CODE" type="xsd:string" minOccurs="0"/>
<xsd:element name="CCY" type="xsd:string" minOccurs="0"/>
<xsd:element name="ACCOUNT_TYPE" type="xsd:string" minOccurs="0"/>
<xsd:element name="CUSTOMER_NAME" type="xsd:string" minOccurs="0"/>
<xsd:element name="AC_DESC" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="QueryAccSumm-Query-IO-Type">
<xsd:sequence>
<xsd:element name="CUST_NO" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="FulAccLstRequest_elm" type="FulAccLstRequest_cpx"/>
<xsd:element name="FulAccLstResponse_elm" type="FulAccLstResponse_cpx"/>
</xsd:schema>
第二个架构
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema targetNamespace="http://www.bea.com/wli/sb/context" xmlns="http://www.bea.com/wli/sb/context"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="fault" type="Fault_cpx"/>
<xsd:complexType mixed="true" name="Fault_cpx">
<xsd:sequence>
<xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute namespace="##any" processContents="lax"/>
</xsd:complexType>
</xsd:schema>
您混淆了 {http://www.bea.com/wli/sb/context}
命名空间中的全局定义元素 fault
,
使用本地定义的,在 {http://www.BM.org/FCUBS/Schemas/FullAccountList}
命名空间中。虽然,这两者
fault
s 看起来一样,它们只有本地名称相同。不然就是完全不同的元素了!
您的第二个(导入的)模式全局定义 fault
。之后,您可以仅通过引用在任何地方使用它。
但正如您在此处指定的那样:
<xsd:complexType name="FulAccLstResponse_cpx">
<xsd:sequence>
<xsd:element name="ResponseStatus" type="FulAccLstResponseStatus_cpx"/>
<xsd:element name="ResponseData" type="FulAccLstResponseData_cpx"/>
<xsd:element name="fault" type="con:Fault_cpx" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
FulAccLstResponse_cpx
类型中的 fault
是本地类型,因此属于架构的目标命名空间。
要使您的 XML 正常工作,您应该按如下方式定义该部分:
<xsd:complexType name="FulAccLstResponse_cpx">
<xsd:sequence>
<xsd:element name="ResponseStatus" type="FulAccLstResponseStatus_cpx"/>
<xsd:element name="ResponseData" type="FulAccLstResponseData_cpx"/>
<xsd:element ref="con:fault" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
P.S.
使用 XML 模式和 WSDL 的人可能会对以下链接感兴趣:
- 高性能通用 XML 带图表的架构文档生成器:http://www.flexdoc.xyz/flexdoc-xml/xsddoc/
- WSDL 和 XSD 相同:http://www.flexdoc.xyz/flexdoc-xml/wsdldoc/
如果您重视我对本网站的参与,请不要删除这些链接!