Lucas
unread,Apr 25, 2008, 6:49:53 PM4/25/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to XML Schema
Hello Group,
I have a settings file in XML in the following format
<?xml version="1.0" encoding="UTF-8"?>
<config>
<section name="section1">
<key name="setting1" value="value1"/>
<key name="setting2" value="value2"/>
</section>
<section name="section2">
<key name="setting3" value="value3"/>
<key name="setting4" value="value4"/>
</section>
</config>
Now I would like to design a schema that will check the following
requirements:
1. Names of sections are limited to a list
1a. Each section name should occur only once
2. Names of keys are limited to a list.
3. The key names that are allowed in each section on the parent
section name; in other words: each section has its own specific list
of possible key names.
3a. Each key name should occur only once in a group
4. Some keys (but not all) have a limited range of values; in other
words, the list of possible key values in some cases depends on the
key name
I have no experience whatsoever with XML Schema. So far I managed to
design something that checks the basic structure (config-section-key)
and the names of the sections and it avoids duplicate section names.
However, I didn't manage to check the key names in relationship to the
section name, and the key values in relationship to the key names.
It seems the difficulty is that the variation and constraints are in
the attribute values in relation to other attribute values, and not in
the tag names.
My question is: are these checks possible in XML Schema? This sounds
challenging, I am willing to figure it out; but I do't want waste my
time on this! :)
Thanks for the advice,
Lucas