gpt4 book ai didi

xml - s4s-att-不允许 : Attribute 'name' cannot appear in element 'simpleType'

转载 作者:数据小太阳 更新时间:2023-10-29 02:56:58 37 4
gpt4 key购买 nike

当我们在 simpleType 中指定名称参数时,我们得到一个错误:

"s4s-att-not-allowed: Attribute 'name' cannot appear in element 'simpleType'."

例如:

 <xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>

这个例子是否正确?为什么会出现上述错误?

最佳答案

您的片段可能正常也可能不正常,这取决于它的上下文。由于您遇到了给定的错误,因此您的上下文似乎是一个本地嵌套定义,其中 @name 是不允许的。

xs:simpleType 在全局使用时可以指定一个名称。这没关系:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

xs:simpleType 在全局使用时不能指定名称。这不行:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="e">
<xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>

解决问题:

要么

  • 删除名称属性,或者
  • lengthValue的定义成为全局的,并引用它使用 @type:

这是一个如何将 @namexs:simpleType 一起使用的示例:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="e" type="lengthValue"/>
</xs:schema>

关于xml - s4s-att-不允许 : Attribute 'name' cannot appear in element 'simpleType' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24863387/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com