Lists Home |
Date Index |
I am new to this list so if I am in the wrong place please point me
I have a question relating to dependencies between parts of an xml document.
So far in the XML books that I have read there is no reference to this
problem that I can find.
I am constructing and transmitting an XML document that gradually gathers
more elements as it travels about. The elements that it gathers are
contributions to the document from different predefined sources - i.e. there
is a pre-established structure to the document, but initially the structure
is just a framework that gets filled in as the document moves from person to
person. My problem is that the elements are interdependent - some elements
cannot be present if others are absent, and vice versa. For example, suppose
the basic structure was:
Initially both <part1> and <part2> are optional. The <_annex>es of <part1>
and <part2> cannot be present without the corresponding <body>s. And the
<binder> element can only be present if both <part1> or <part2> are present
The only way I can find of representing this arrangement in a schema or dtd
is to have a different schema or dtd at each state of the document. In the
first "Incomplete" state, <part1/part2> are both optional, and within each
the <body> is mandatory and the <_annex>es are optional. The <binder> part
is absent altogether.
Once I have <part1> and <part2> completed, i.e. all bodies and annexes
present, the document moves to the "ready to bind" state, in which all the
<part1/part2> <body>s and <_annex>es become mandatory and the <binder> part
appears as an optional element.
Finally, when the <binder> element is added the whole document is complete
and moves to the "Bound" state in which all elements are mandatory.
Using a separate schema for each of the three states turns out to be a very
clumsy way of handling things. In the example above it is just about
manageable but where there are many levels and elements/sub elements it is
almost impossible to represent. How can I easily define the interdependence
between all these parts within a single schema or dtd, so that the document
can move through different states, each state having different rules about
the presence or absence of the different parts?