[Home] [By Thread] [By Date] [Recent Entries]

  • From: Roger L Costello <costello@m...>
  • To: "xml-dev@l..." <xml-dev@l...>
  • 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]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member