L
Lemon Tree
Hello everybody.
I have a problem with Schema Definitions and I cannot figure out how to
solve it (provided that it could be solved ) Here we go...
Let's suppose to have a simple XML file with the following tags:
<type id="id1"/>
<type id="id2"/>
<type id="id3"/>
Now I would like to express, by using an XSD, the following restriction
on a tag attribute: the value of the attribute must be the value of the
id attribute of some previously defined <type> tag.
For example, let's suppose to have a <foo> tag with a "type" attribute.
Then the admissible values for the "type" attribute would be id1, id2
or id3.
At the beginning I thought it was not possible but, while I was writing
an XSD I noticed that I was doing the previously described thing all
the time!!! In fact, my XSD are full of type declarations like
<xs:complexType name="myTypeName">
...
</xs:complexType>
and these declarations are used to define the type of elements, for
example
<xs:element type="myTypeName"> ...
The validator complains if the value of the "type" attribute has not
been previously defined
That's exactly the thing I would like to do with my XML files
I saw the XSD of the XSD but it is too complicated and by looking at it
I cannot understand if this kind of enforcement (using declared types)
can be embedded in the XSD itself or it is part of an ad-hoc logic of
the validator program.
I still think that it is not possible to enforce such a kind of
restriction by simply using XSD files but I might be wrong. Any hint?
Thank you
I have a problem with Schema Definitions and I cannot figure out how to
solve it (provided that it could be solved ) Here we go...
Let's suppose to have a simple XML file with the following tags:
<type id="id1"/>
<type id="id2"/>
<type id="id3"/>
Now I would like to express, by using an XSD, the following restriction
on a tag attribute: the value of the attribute must be the value of the
id attribute of some previously defined <type> tag.
For example, let's suppose to have a <foo> tag with a "type" attribute.
Then the admissible values for the "type" attribute would be id1, id2
or id3.
At the beginning I thought it was not possible but, while I was writing
an XSD I noticed that I was doing the previously described thing all
the time!!! In fact, my XSD are full of type declarations like
<xs:complexType name="myTypeName">
...
</xs:complexType>
and these declarations are used to define the type of elements, for
example
<xs:element type="myTypeName"> ...
The validator complains if the value of the "type" attribute has not
been previously defined
That's exactly the thing I would like to do with my XML files
I saw the XSD of the XSD but it is too complicated and by looking at it
I cannot understand if this kind of enforcement (using declared types)
can be embedded in the XSD itself or it is part of an ad-hoc logic of
the validator program.
I still think that it is not possible to enforce such a kind of
restriction by simply using XSD files but I might be wrong. Any hint?
Thank you