xsd:attribute 声明在全局 xsd:complexType 中的什么位置?
Where does xsd:attribute declaration go in global xsd:complexType?
我想声明一个已经定义的元素的属性。我希望元素 person
可以有 2 个属性(name
、id
)我有这个:
<xs:element name="person" type="perso" />
<xs:complexType name="perso">
<!-- I tried to declare the attribute here.Not working-->
<xs:sequence>
<!-- I tried to declare the attribute here.Not working-->
<xs:element name="description" type="xs:string" />
</xs:sequence>
</xs:complexType>
我希望声明一个全局而非局部的复杂类型。我对混合内容不感兴趣。
我收到的错误消息:
element attribute: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}sequence': The content is not valid. Expected is (annotation?, (element | group | choice | sequence | any)*).
属性声明在 xs:sequence
:
之后
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="person" type="perso" />
<xs:complexType name="perso">
<xs:sequence>
<xs:element name="description" type="xs:string" />
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
</xs:schema>
我想声明一个已经定义的元素的属性。我希望元素 person
可以有 2 个属性(name
、id
)我有这个:
<xs:element name="person" type="perso" />
<xs:complexType name="perso">
<!-- I tried to declare the attribute here.Not working-->
<xs:sequence>
<!-- I tried to declare the attribute here.Not working-->
<xs:element name="description" type="xs:string" />
</xs:sequence>
</xs:complexType>
我希望声明一个全局而非局部的复杂类型。我对混合内容不感兴趣。
我收到的错误消息:
element attribute: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}sequence': The content is not valid. Expected is (annotation?, (element | group | choice | sequence | any)*).
属性声明在 xs:sequence
:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="person" type="perso" />
<xs:complexType name="perso">
<xs:sequence>
<xs:element name="description" type="xs:string" />
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
</xs:schema>