Hierarchical Schema File Organization

Scott Brady Drummonds

Usenet Archive
Joined
Jul 3, 2003
Messages
37
Reaction score
0
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
 

Scott Brady Drummonds

Usenet Archive
Joined
Jul 3, 2003
Messages
37
Reaction score
0
Scott Brady Drummonds said:
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
 

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
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top