- From: King, Jeffrey (Mission Systems) <Jeff.King@ngc.com>
- Date: Fri, 4 Jan 2008 08:29:26 -0600
- To: <xmlschema-dev@w3.org>
- Message-ID: <2A77548F22867A4B8C38F7608F3B40CC5721CF@XMBIL132.northgrum.com>
I have an xml document similar to this:
<root>
<word name="one">
<field name="field1" number="1">any string here</field>
<field name="field2" number="2">any string here</field>
<field name="field3" number="3">any string here</field>
...
</word>
<word name="two">
<field name="field4" number="4">any string here</field>
<field name="field5" number="5">any string here</field>
<field name="field6" number="6">any string here</field>
...
</word>
</root>
The attributes have fixed values. I am struggling to create a schema
for this.
If I take this approach:
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="word">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="field">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"
use="required" fixed="field1" />
<xs:attribute name="number"
type="xs:unsignedShort" use="required" fixed="1" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="field">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"
use="required" fixed="field2" />
<xs:attribute name="number"
type="xs:unsignedShort" use="required" fixed="2" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
...
etc.
I get an error stating: "Elements with the same name and in the same
scope must have the same type". I'm not sure what approach to take
here. I think this is pretty elementary, but any help with finding a
solution would be appreciated.
Thank you.
Jeffrey
Received on Friday, 4 January 2008 15:00:40 UTC