I'm fairly new to XML, and to coding in general.
I'm trying to validate an XML markup with a schema that I've put together. One of my elements utilizes the xml:id attribute. It looks like this: <item xml:id="MAT_10_23">
. In my schema, I've followed the recommended structure with <xs:attribute name="id" type="xs:ID"/>
in the element declaration. Here it is in full:
<xs:element name="item">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="label">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
When I try to validate this my markup, however, I'm told that "Attribute xml:id is not allowed to appear in the element ". I've tried declaring the attribute separately in my schema separately. This is what it looks like:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:attribute name="id" type="xs:ID"/>
But this does not change anything. What do I need to change in my schema to successfully validate my XML markup?