[Home] [By Thread] [By Date] [Recent Entries]
Hi Folks,
Thank you for your responses. Very good, ref'ing multiple times to a global element declaration does not violate DRY.
Below I have slightly modified the XML Schema. I created an xs:group and placed the ref's to Title and Publisher inside the xs:group. Now the Book and Magazine elements ref to the xs:group. In the previous XML Schema design there were two ref's to Title and two ref's to Publisher:
<xs:element ref="Title" />
<xs:element ref="Title" />
<xs:element ref="Publisher" />
<xs:element ref="Publisher" />
In the new design there is only one ref to Title and one ref to Publisher (the ref's are inside xs:group). But now there are two ref's to the xs:group
<xs:group ref="Title-and-Publisher" />
<xs:group ref="Title-and-Publisher" />
In the previous design there were four ref's:
<xs:element ref="Title" />
<xs:element ref="Title" />
<xs:element ref="Publisher" />
<xs:element ref="Publisher" />
In the new design there are also four ref's:
<xs:group ref="Title-and-Publisher" />
<xs:group ref="Title-and-Publisher" />
<xs:element ref="Title" />
<xs:element ref="Publisher" />
Suppose Book and Magazine have three common elements: Title, Publisher, and Author. In the old design there would be six ref's:
<xs:element ref="Title" />
<xs:element ref="Title" />
<xs:element ref="Publisher" />
<xs:element ref="Publisher" />
<xs:element ref="Author" />
<xs:element ref="Author" />
In the new design there would be five ref's:
<xs:group ref="Title-and-Publisher-and-Author" />
<xs:group ref="Title-and-Publisher-and-Author" />
<xs:element ref="Title" />
<xs:element ref="Publisher" />
<xs:element ref="Author" />
You have stated that ref's do not violate DRY. Here we see an opportunity to reduce the number of ref's by using xs:group. Is a design that uses less ref's more DRY-compliant than a design that uses more ref's? /Roger
----------------------------------------------
<xs:element name="Bookstore">
<xs:complexType>
<xs:sequence>
<xs:element name="Book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:group ref="Title-and-Publisher" />
...
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Magazine" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:group ref="Title-and-Publisher" />
...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="Title-and-Publisher">
<xs:sequence>
<xs:element ref="Title" />
<xs:element ref="Publisher" />
</xs:sequence>
</xs:group>
<xs:element name="Title" type="xs:string" />
<xs:element name="Publisher" type="xs:string" />
...
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |

Cart



