Schema definition for a generic XML structure

Discussion in 'XML' started by Ben, Jul 30, 2003.

  1. Ben

    Ben Guest

    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
    Ben, Jul 30, 2003
    #1
    1. Advertising

  2. (Ben) writes:

    > 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
    C. M. Sperberg-McQueen, Jul 31, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,497
    Markus
    Nov 23, 2005
  2. chobin
    Replies:
    0
    Views:
    423
    chobin
    Dec 10, 2003
  3. Abhinav
    Replies:
    6
    Views:
    1,060
    Abhinav
    Aug 16, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,173
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    2,797
Loading...

Share This Page