XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] [XSD question] Does ref'ing to the same global elementdeclaration multiple times violate the Don't Repeat Yourself principle?

The global versus local debate?

The alternative, although gaining popularity in software (mainly because of microservices routinely violating DRY) , is to repeat Title even more, by declaring it locally, and each repetition would get its own evolutionary path of attributes, etc. Yes? That would violate DRY even more since these attributes would likely be very similar in semantics but not quite the same in syntax (spelling, datatypes), and code based on this schema would be likely to have to reproduce those DRY violations and need lots of mappings.

On Thu, 6 Jan 2022 at 12:44, Roger L Costello <costello@mitre.org> wrote:
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" />
...

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

--
----
Stephen D Green


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS