xs:anyAttributes拒绝属性

bma*_*ies 3 xsd

在我的架构中,我有:

<xs:element name="html-script">
    <xs:annotation>
       <xs:documentation>Element used to specify pass-through Javascript</xs:documentation>
    </xs:annotation>
   <xs:complexType>
     <xs:simpleContent>
       <xs:extension base="xs:string">
         <xs:anyAttribute/>
       </xs:extension>
     </xs:simpleContent>
  </xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)

在我的文件中:

<html-attributes target="_new"/>
Run Code Online (Sandbox Code Playgroud)

当我验证时,我得到......

验证错误:cvc-complex-type.3.2.2:不允许在元素'html-attributes'中出现属性'target'.在文件:/ Users/benson/x/btweb/web_2_0 /./ content/about-us/about-us.xml第35行38

我错过了什么?

Fil*_*urt 10

可能错字?您的架构定义了<html-script>文档使用的元素<html-attributes>.

还可以尝试将processContents指令添加到anyAttribute:

<xs:anyAttribute processContents="skip" />
Run Code Online (Sandbox Code Playgroud)

要么

<xs:anyAttribute processContents="lax" />
Run Code Online (Sandbox Code Playgroud)

  • 遇到了同样的问题,添加`processContents =“ skip”`对我有用。 (2认同)