[英]cvc-datatype-valid.1.2.1: 'mylns:xsi' is not a valid value for 'NCName'
The Schema : 架构:
<xs:complexType>
<xs:sequence>
<xs:element ref="FileCreationList"/>
<xs:element ref="DivestedExample"/>
</xs:sequence>
<xs:attribute name="mylns:xsi" type="xs:string"/>
<xs:attribute name="xsi:schemaLocation" type="xs:string"/>
</xs:complexType>
The error: 错误:
Multiple annotations found at this line:
- s4s-att-invalid-value: Invalid attribute value for 'name' in element 'attribute'. Recorded reason: cvc-datatype-valid.1.2.1: 'mylns:xsi' is not a valid
value for 'NCName'.
- src-attribute.3.1: One of 'ref' or 'name' must be present in a local attribute declaration.
- s4s-elt-invalid-content.1: The content of '#AnonType_File' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often.
Attribute name declarations must be NCNames (non-colonized names): 属性名称声明必须是NCNames (非殖民化名称):
NCName ::= (Letter | '_') (NCNameChar)* /* An XML Name, minus the ":" */
Remove the colons from mylns:xsi
and xsi:schemaLocation
to eliminate the error. 从
mylns:xsi
删除冒号mylns:xsi
和xsi:schemaLocation
以消除错误。
Notes : 备注 :
Do not declare xsi:schemaLocation
as an attribute in an XSD; 不要将
xsi:schemaLocation
声明为XSD中的属性; declare and reference the http://www.w3.org/2001/XMLSchema-instance
namespace: 声明并引用
http://www.w3.org/2001/XMLSchema-instance
命名空间:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/name try.xsd"/>
Generally, if you want to declare an element that uses attributes in a different namespace, then you need to (a) declare those attributes in a separate XSD document, with a different targetNamespace, (b) use xs:import to import that XSD document, and (c) reference the attribute declarations using <xs:attribute ref="somens:localname"/>
. 通常,如果要声明在不同命名空间中使用属性的元素,则需要(a)在单独的XSD文档中使用不同的targetNamespace声明这些属性,(b)使用xs:import导入该XSD文档,(c)使用
<xs:attribute ref="somens:localname"/>
引用属性声明。
However: 然而:
(i) Namespace declarations (xmlns:xx="uri") are not considered to be attributes and do not need to be declared (indeed, must not be declared) in the schema (i)名称空间声明(xmlns:xx =“uri”)不被视为属性,不需要在模式中声明(实际上,不得声明)
(ii) Attributes in the "xsi" namespace are special - they are automatically allowed on every element, and should not be declared in the schema. (ii)“xsi”命名空间中的属性是特殊的 - 它们在每个元素上自动被允许,不应在模式中声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.