G
Gerry Laenen
Hi all,
I am currently working on creating an XSD schema. I have an element defined
that should be self-refering (child-parent principle). Here is a sample:
<GWLC>
<GROUPS>
<GROUP>
<NAME>ParentGroup</NAME>
<PARENT></PARENT>
</GROUP>
<GROUP>
<NAME>ChildGroup1</NAME>
<PARENT>ParentGroup</PARENT>
</GROUP>
</GROUPS>
</GWLC>
The schema a currently have is valid, but it does not validate the existance
of a parent group (foreignkey constraint). Secondly, I want each name to be
uniqe. The applicable section off the schema:
<!-- ************************************ -->
<!-- * Description of the GROUPS element* -->
<!-- ************************************ -->
<xs:element name="GROUPS" id="GROUPS">
<xs:complexType>
<xs:sequence>
<xs:element ref="GROUP" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="UC_Group">
<xs:selector xpath="./GROUP"></xs:selector>
<xs:field xpath="NAME"></xs:field>
</xs:unique>
</xs:element>
<!-- *********************************** -->
<!-- * Description of the GROUP element* -->
<!-- *********************************** -->
<xs:element name="GROUP" id="GROUP">
<xs:complexType>
<xs:sequence>
<xs:element name="NAME"/>
<xs:element name="PARENT"/>
</xs:sequence>
</xs:complexType>
<xs:key name="PK_GROUP">
<xs:selector xpath=".//GROUP"/>
<xs:field xpath="NAME"/>
</xs:key>
<xs:keyref name="FK_GROUP_GROUP" refer="PK_GROUP">
<xs:selector xpath=".//GROUP"/>
<xs:field xpath="PARENT"/>
</xs:keyref>
</xs:element>
Thanks for helping!
Gerry
I am currently working on creating an XSD schema. I have an element defined
that should be self-refering (child-parent principle). Here is a sample:
<GWLC>
<GROUPS>
<GROUP>
<NAME>ParentGroup</NAME>
<PARENT></PARENT>
</GROUP>
<GROUP>
<NAME>ChildGroup1</NAME>
<PARENT>ParentGroup</PARENT>
</GROUP>
</GROUPS>
</GWLC>
The schema a currently have is valid, but it does not validate the existance
of a parent group (foreignkey constraint). Secondly, I want each name to be
uniqe. The applicable section off the schema:
<!-- ************************************ -->
<!-- * Description of the GROUPS element* -->
<!-- ************************************ -->
<xs:element name="GROUPS" id="GROUPS">
<xs:complexType>
<xs:sequence>
<xs:element ref="GROUP" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="UC_Group">
<xs:selector xpath="./GROUP"></xs:selector>
<xs:field xpath="NAME"></xs:field>
</xs:unique>
</xs:element>
<!-- *********************************** -->
<!-- * Description of the GROUP element* -->
<!-- *********************************** -->
<xs:element name="GROUP" id="GROUP">
<xs:complexType>
<xs:sequence>
<xs:element name="NAME"/>
<xs:element name="PARENT"/>
</xs:sequence>
</xs:complexType>
<xs:key name="PK_GROUP">
<xs:selector xpath=".//GROUP"/>
<xs:field xpath="NAME"/>
</xs:key>
<xs:keyref name="FK_GROUP_GROUP" refer="PK_GROUP">
<xs:selector xpath=".//GROUP"/>
<xs:field xpath="PARENT"/>
</xs:keyref>
</xs:element>
Thanks for helping!
Gerry