You need to define a complexType
with a simpleContent
:
<xs:element name="AnElement">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:int">
<xs:attribute name="ID" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
That should do the trick. And I'm afraid that's the only way to achieve this. Is it really so bad??
UPDATE:
After your update, this is the XSD you'll need:
<xs:schema id="TheParentNode" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="TheParentNode">
<xs:complexType>
<xs:sequence>
<xs:element name="AnElement">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:int">
<xs:attribute name="ID" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
You are aware I hope that if you have the XML file open in Visual Studio, you can go to the "XML" menu and pick "Create schema" from it? That does give you a good start usually for your XSD files.
Marc
marc_s
2009-07-22 20:51:07