Author Topic: How to generate XSD with key/keyref  (Read 3255 times)

Stan

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
How to generate XSD with key/keyref
« on: August 17, 2005, 10:45:38 am »
Hello.
Is there any way how to generate from class diagram (contains 2 tables linked by foreign key) XSD file with constraints?

Something like this?
Code: [Select]

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:element name="table1">


<xs:annotation>



<xs:documentation>Comment describing your root element</xs:documentation>


</xs:annotation>


<xs:complexType>



<xs:sequence>




<xs:element name="table2" minOccurs="0" maxOccurs="unbounded">





<xs:complexType>






<xs:attribute name="table2_id" type="xs:int" use="required"/>






<xs:attribute name="table1_id" type="xs:int" use="required"/>





</xs:complexType>





<xs:key name="PK_table2_id">






<xs:selector xpath="."/>






<xs:field xpath="@table2_id"/>





</xs:key>




</xs:element>



</xs:sequence>



<xs:attribute name="table1_id" type="xs:int" use="required"/>


</xs:complexType>


<xs:key name="PK_table1">



<xs:selector xpath="."/>



<xs:field xpath="@table1_id"/>


</xs:key>


<xs:keyref name="FK_table2" refer="PK_table1">



<xs:selector xpath="table2"/>



<xs:field xpath="@table1_id"/>


</xs:keyref>

</xs:element>
</xs:schema>


thanks

--
Kamil