Schema definition for a generic XML structure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    #1

    Schema definition for a generic XML structure

    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>
    <MessageHeade r 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:complexTyp e>
    <xsd:sequence >
    <xsd:element ref="MessageHea der"/>
    <xsd:element ref="MessageBod y"/>
    </xsd:sequence>
    </xsd:complexType >
    </xsd:element>
    <xsd:element name="MessageBo dy">
    <xsd:complexTyp e/>
    </xsd:element>
    <xsd:element name="MessageHe ader">
    <xsd:complexTyp e>
    <xsd:attribut e name="action" type="xsd:strin g" use="optional"/>
    <xsd:attribut e name="appID" type="xsd:strin g" 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(schem a #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. M. Sperberg-McQueen

    #2
    Re: Schema definition for a generic XML structure

    benstucky@hotma il.com (Ben) writes:
    [color=blue]
    > 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.[/color]

    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

    Comment

    Working...