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] RE: [XSD question] Does ref'ing to the sameglobal element declaration multiple times violate the Don't RepeatYourself principle?

I'm not sure whether there is a fixed definition for "DRY-complicancy", but I think that it's worth noting that DRY is not the only principle that's worth aiming for: code clarity and maintainability are also important considerations, and I'm not convinced that too many group definitions of the sort you use here help with that: don't forget that the number of combinations for the groups you need to declare for N definitions potentially scale factorially!

Thanks,
Tom
On 6 Jan 2022, 14:42 +0000, Roger L Costello <costello@mitre.org>, wrote:
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" />
...

_______________________________________________________________________

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



[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