 |
 |
 |
Is it possible with XSD schemas or RELAX-NG to constrain the occurrences
of elements in a certain context to be isomorphic with respect to
structure: to have the same sub-elements and attributes in that context
(among the subelements and attributes allowed by their content model) ?
In particular, I would like to able to constrain the child elements of
an element to all have the same sub elements and attributes as each
other. (I would like the branches of an element to be isomporphic,as
long as the isomorphism respects the content model)
For instance, in the following schema I would like to constrain the
child elements ('b') of 'a' to be isomorphic :
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:element ref="b" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="b">
<xs:complexType>
<xs:choice>
<xs:element ref="c" minOccurs="1" maxOccurs="unbounded" />
<xs:element ref="d" minOccurs="1" maxOccurs="unbounded" />
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="c">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="c_attr1" type="xs:ID"/>
<xs:attribute name="c_attr2" type="xs:ID"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="d">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="d_attr1" type="xs:ID"/>
<xs:attribute name="d_attr2" type="xs:ID"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
I would like the following 2 instance documents to be valid :
<?xml version="1.0" encoding="iso-8859-1"?>
<a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<b>
<c c_attr1="ezrz">sdfgdfg</c>
</b>
<b>
<c c_attr1="gfhf">sdfgdfg</c>
</b>
</a>
<?xml version="1.0" encoding="iso-8859-1"?>
<a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<b>
<d d_attr2="ezrz">sdfgdfg</d>
</b>
<b>
<d d_attr2="gfhf">sdfgdfg</d>
</b>
</a>
And the following 2 instance documents to be invalid (because structure of 'b' sin't isomorphic)
<?xml version="1.0" encoding="iso-8859-1"?>
<a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<b>
<d d_attr2="ezrz">sdfgdfg</d>
</b>
<b>
<c c_attr2="gfhf">sdfgdfg</c>
</b>
</a>
<?xml version="1.0" encoding="iso-8859-1"?>
<a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<b>
<c c_attr1="ezrz">sdfgdfg</c>
</b>
<b>
<c c_attr2="gfhf">sdfgdfg</c>
</b>
</a>
I don't know how to express this kind of contextual constraint. Thanks a lot.
Helka F.
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |