Hi Arndt,
"Arndt Jonasson" <ar************@gmail.comwrites:
My question deals with how best to specify additional parameters of
the
"ref" type. One thing I'd like to be able to say is "the element
pointed
to by the location path must actually exist", respectively "does not
have to exist" (elements can be created and destroyed in runtime).
This can be expressed with an attribute to the <e/element:
<e name="e3" type="types:ref" must_exist="true"/>
My question is: is this a proper way of doing it? It seems slightly
peculiar to supply the general </eelement with an attribute which
will only be valid for one particular value of another attribute.
(Of course I can make a "types:ref_must_exists" type, but there will
be more complicated ways to restrict the type.)
Your must_exist attribute is changing the ref type, not the element
so it naturally belongs to the type definition. XML Schema does this
by allowing you to create a new type that restrict the original. In
your case it could look like so:
<t name="my_t">
<r base="types:ref" must_exist="true"/>
</t>
<e name="e3" type="my_t"/>
You could have several attributes/elements like must_exist that
change different aspects of different types.
hth,
-boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding