[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
[XSD question] Does ref'ing to the same global element declarationmultiple times violate the Don't Repeat Yourself principle?
- From: Roger L Costello <costello@mitre.org>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Thu, 6 Jan 2022 12:44:47 +0000
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" />
...
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]