An element can also contain child elements that contain attributes. To specify such elements, you need to specify the attribute declaration within the child element declaration. For example, consider the following XML document declaration:
<Message>
<Sender_Name location=”anyplace”>ABC</Sender_Name>
<Address>XYZ</Address>
</Message>
The following code snippet displays the associated XML schema declaration for the preceding XML document declaration:
<xs:element name="Message">
<xs:complexType>
<xs:sequence>
<xs:element name="Sender_Name" type="xs:string">
<xs:complexType>
<xs:attribute name="location" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
|