Due to my unfamiliarity with schemas, I am unable to figure out how to
accomplish the same type of processing that I have currently working
under a dtd. We have a pre-defined generic message header that must
appear on all XML messages in our shop. We have several processes
that just need to process the generic header to determine how to route
the message and which service needs to process the message. So we
have an XML structure that at a high level looks like this:
<Message>
<MessageHeader appID="" action=""></MessageHeader>
<MessageBody></MessageBody>
</Message>
The MessageBody gets redefined with application specific data. The
generic process does not need to know about the contents of the
MessageBody. The specific application reparses the message,
validating the contents and getting at its information. This a
relatively straight forward process but for the life of me I can't
seem figure out how to define this relationship properly in a schema.
With my current level of schema knowledge and using the above XML
example I would think I would start with the following as a base:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Message">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="MessageHeader"/>
<xsd:element ref="MessageBody"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="MessageBody">
<xsd:complexType/>
</xsd:element>
<xsd:element name="MessageHeader">
<xsd:complexType>
<xsd:attribute name="action" type="xsd:string" use="optional"/>
<xsd:attribute name="appID" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
1) Is how I am defining this base schema (schema #1) wrong?
2) If I define this generic structure(schema #1) as my base, how do a
change this base to flesh out the MessageBody in another schema
(schema #2)? NOTE: I would still need to be able to parse/validate the
resulting XML defined by schema#2 using the schema #1 definition.
Thanks,
Ben