← Prev in month
← Prev in thread
[XSD question] Does ref'ing to the same global element declaration multiple times violate the Don't Repeat Yourself principle?
Hi Folks,
Below is an XML Schema for a Bookstore. The Bookstore has any number of Books followed by any number of Magazines. Each Book has a Title and Publisher (and other things). Each Magazine also has a Title and Publisher (and other things). The Book element ref's to a globally declared Title element and ref's to a globally declared Publisher element. Ditto for the Magazine element.
Title is declared once:
<xs:element name="Title" type="xs:string" />
but ref'ed twice (once from Book and once from Magazine):
<xs:element ref="Title" />
<xs:element ref="Title" />
Ditto for Publisher.
Do multiple ref's to the same element constitute a violation of the Don't Repeat Yourself (DRY) principle? /Roger
-----------------------------------------------
<xs:element name="Bookstore">
<xs:complexType>
<xs:sequence>
<xs:element name="Book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="Title" />
<xs:element ref="Publisher" />
...
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Magazine" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="Title" />
<xs:element ref="Publisher" />
...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Title" type="xs:string" />
<xs:element name="Publisher" type="xs:string" />
...
← Prev in month
← Prev in thread