【发布时间】:2017-02-06 22:43:03
【问题描述】:
我有一个 xsd:
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
我想将属性“Attribute1”添加到“firstname”元素:
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string">
<xs:attribute name="Attribute1" type="xs:string/>
</xs:element>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
执行此操作时,我收到一条错误消息:“此上下文不支持 'http://www.w3.org/2001/XMLSchema:attribute' 元素。”
将属性分配给元素“名字”的正确方法是什么?
【问题讨论】: