Abstract and Schema

J

Jason Cavett

I'm attempting to create a schema where I have an abstract model from
which all other nodes "extend" the model (so I don't need to retype
the same information repeatedly). Something like this...

<xs:complexType name="DataModel" abstract="true">
<xs:complexContent>
<xs:extension base="DataModel">
<xs:sequence>
<xs:element name="data">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="children">
<xs:complexType>
<xs:sequence>
<xs:element name="Notes" type="NotesModel"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

However, what I do not understand is - when I create the other
elements that rely on DataModel...how do I continue to expand the
existing nodes. (For example, I want to add additional elements to
the "children" node.)


Thanks
 
J

Joseph Kesselman

Jason said:
However, what I do not understand is - when I create the other
elements that rely on DataModel...how do I continue to expand the
existing nodes. (For example, I want to add additional elements to
the "children" node.)

You can't override existing element definitions. <children> will always
have the contents it originally had, unless you replace the basic schema.

What you can do is define a type for the element, define new types which
extend that type, and define new elements which implement the extended
type. Then, if you say that what's expected at that point in the
document is an instance of the base type, elements having any of the
extended types will also be accepted.

See, for example, XML Schema Part 0's example of deriving types by
extension:
http://www.w3.org/TR/xmlschema-0/#DerivExt
and related sections.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top