You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

XML与XSD验证失败:双Schema验证时的元素匹配报错排查

XML Schema Validation Failure: Mismatched Fault Element Namespace

First, let's recap the core validation errors you're facing:

第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'

Let's break down the root cause and fix it step by step.

Problem Analysis

The mismatch comes down to conflicting namespace expectations between your XML and Schema definitions:

  1. Your XML's fault element: It uses the bea context namespace (http://www.bea.com/wli/sb/context) via the con: prefix:
    <con:fault xmlns:con="http://www.bea.com/wli/sb/context">
    
  2. Your main Schema's fault definition: In the FulAccLstResponse_cpx complex type, you've defined a fault element in your main namespace (http://www.BM.org/FCUBS/Schemas/FullAccountList) that uses the bea Fault_cpx type:
    <xsd:element name="fault" type="con:Fault_cpx" minOccurs="0"/>
    
  3. The second Schema: It defines a standalone fault element in the bea namespace, but your main Schema only imports its type—not the element itself.

The validator fails because it expects a fault element in your main namespace, but your XML provides one in the bea namespace instead.

Fix Options

You have two straightforward solutions, depending on whether you can modify the XML or prefer to adjust the Schema.

Option 1: Adjust the XML to Match the Schema

Modify the fault element to belong to your main namespace, while keeping its child elements in the bea namespace (since that's what the con:Fault_cpx type expects):

<FulAccLstResponse_elm xmlns="http://www.BM.org/FCUBS/Schemas/FullAccountList">
  <ResponseStatus>
    <Code>444</Code>
    <Description>Invalid Input Parameters</Description>
  </ResponseStatus>
  <ResponseData/>
  <!-- Change con:fault to fault (uses main namespace) -->
  <fault>
    <!-- Keep con prefix for child elements (bea namespace) -->
    <con:errorCode xmlns:con="http://www.bea.com/wli/sb/context">382505</con:errorCode>
    <con:reason xmlns:con="http://www.bea.com/wli/sb/context">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>
  </fault>
</FulAccLstResponse_elm>

Option 2: Modify the Schema to Accept the Existing XML

If you can't change the XML (e.g., it's generated by an external system), update your main Schema to reference the bea namespace's fault element directly, instead of defining a new one in your main namespace:

In the FulAccLstResponse_cpx complex type, replace this line:

<xsd:element name="fault" type="con:Fault_cpx" minOccurs="0"/>

With this:

<xsd:element ref="con:fault" minOccurs="0"/>

This tells the Schema to accept the fault element from the bea namespace (con:fault) that your XML is already using, since the second Schema already defines that element.

Final Notes

  • If you control both the XML and Schema, Option 1 aligns with the original Schema design (keeping the response structure in your main namespace).
  • If the XML is fixed, Option 2 is the better choice—it adapts the Schema to the existing XML format without breaking other parts of your validation.

内容的提问来源于stack exchange,提问作者Heba Gaafar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:19:26