Schema definition for a generic XML structure

B

Ben

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
 
C

C. M. Sperberg-McQueen

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.

Can you show us the part of the DTD that makes it work. I would
be surprised if there is anything much you can do with XML DTDs
that you cannot do with XML Schema documents (or Relax NG, or
most other languages for XML schemas). [There are, to be sure,
some parameter-entity tricks which cannot be replicated using
XML Schema constructs -- but if you really find your back to the wall,
you can always replicate those parameter-entity tricks
using general entities.]

-C. M. Sperberg-McQueen
World Wide Web Consortium
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top