使用模式验证xml时,我有2个schema,验证错误
第10行:此处为预期元素'fault @ http://www.BM.org/FCUBS/Schemas/FullAccountList',而不是'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>
答案 0 :(得分:0)
您混淆了fault
命名空间中的全局定义元素{http://www.bea.com/wli/sb/context}
,
与本地定义的名称(位于{http://www.BM.org/FCUBS/Schemas/FullAccountList}
名称空间中)。虽然,这两个
fault
看起来像一样,只有本地名称相同。否则,它们是完全不同的元素!
您的第二个(导入的)架构全局定义了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>
fault
类型中的FulAccLstResponse_cpx
是本地类型,因此属于架构的目标名称空间。
要使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的人来说,以下链接可能很有趣:
如果您重视我对本网站的参与,请不要删除这些链接!