Hierarchical Schema File Organization

Discussion in 'XML' started by Scott Brady Drummonds, Nov 17, 2004.

  1. Hi, everyone,

    I'm designing my first XML-based application and am stuck on an issue that I
    presume is pretty simple. I'm trying to write a schema that can be used to
    validate my XML file. However, I want to define components of this schema
    in different files so that I can do isolated tests on these subsections. As
    an example, consider this XML file:

    <container>
    <name>Me</name>
    <object>
    ...
    </object>
    </container>

    In my program, there is a class for the 'container' type and a class for the
    'object' type. I'd like to be able to make a unit test for my 'object' XML
    I/O as well as the 'container' XML I/O. However, to do this I need a schema
    for both types. Then, to avoid redundancy, I don't want the 'container'
    schema to define how the 'object' component will look. I'd prefer to have
    the 'container' schema refer to the 'object' schema which will be defined in
    another file.

    Can this be done? If not, is there a better way to set up unit tests for my
    components so that I can verify that they work in isolation before trying to
    use the 'object' code in the 'container' code?

    Thanks!
    Scott

    --
    Remove .nospam from my e-mail address to mail me.

    http://www.e-scott.net
     
    Scott Brady Drummonds, Nov 17, 2004
    #1
    1. Advertising

  2. "Scott Brady Drummonds" <> wrote in
    message news:cne726$6sq$...
    > Hi, everyone,
    >
    > I'm designing my first XML-based application and am stuck on an issue that

    I
    > presume is pretty simple. I'm trying to write a schema that can be used

    to
    > validate my XML file. However, I want to define components of this schema
    > in different files so that I can do isolated tests on these subsections.

    As
    > an example, consider this XML file:


    A couple of days later I found a book that had my answer. I'm posting a
    synopsis here for posterity.

    The key here is the use of the <import> tag in the <schema> section. In the
    top-level schema file definition, calling <import> on the file that contains
    definitions that are needed and specifying the a namespace prefix for the
    namespace, definitions in the other file can be referenced through the
    <element> tag's "ref" attribute. Therefore definitions in one XML schema
    file can be used in another.

    Scott
     
    Scott Brady Drummonds, Nov 19, 2004
    #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.

Share This Page