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

XML Schema校验报错:元素不允许出现id属性,求解决办法

Fixing the cvc-complex-type.3.2.2 Attribute Error in XML Schema Validation

Hey there! Let's get this validation error sorted out for you. The error you're seeing (cvc-complex-type.3.2.2: Attribute 'id' is not allowed to appear in element 'System') has two key issues we need to address:

1. The id attribute isn't declared in your XSD

Your XML's <A:System> element includes an id attribute, but your current XSD doesn't specify that this attribute is allowed for the System element. To fix this, you need to add an <xs:attribute> definition inside the xs:complexType block of the System element.

Updated XSD with id attribute support:

<xs:element name="System" maxOccurs="unbounded"> 
  <xs:complexType> 
    <xs:sequence> 
      <xs:element name="SystemCd" /> 
    </xs:sequence>
    <!-- Add this to declare the 'id' attribute -->
    <xs:attribute name="id" type="xs:string" use="required" />
  </xs:complexType> 
</xs:element>
  • Use use="required" if the id attribute must always be present (like in your XML example). If it's optional, change this to use="optional" or omit the use attribute entirely (optional is the default behavior).

2. Mismatched opening/closing XML tags

Looking at your XML snippet, there's a critical tag mismatch: you start with <A:System> but close with </A:SourceSystem>. This will cause a separate validation error even after fixing the attribute issue. Correct the closing tag to match the opening one:

Corrected XML:

<A:System id="systemName"> 
  <A:SystemCd>001</A:SystemCd> 
</A:System>

Apply both these fixes, and your XML should validate against the updated XSD without any errors.

内容的提问来源于stack exchange,提问作者Robert Price

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 03:57:29