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: Do not use the same tag name for different things ... Do youagree?

"Question: Beside violating the DRY principle, are there other reasons to avoid using the same tag name for different things?"

Uhh, hard to verify, but I think that there is a special place in hell where everything has the same name...

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br        brutzman@nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA    +1.831.656.2149
X3D graphics, virtual worlds, Navy robotics https:// faculty.nps.edu/brutzman

-----Original Message-----
From: Roger L Costello <costello@mitre.org> 
Sent: Wednesday, January 19, 2022 10:53 AM
To: xml-dev@lists.xml.org
Subject: [xml-dev] Do not use the same tag name for different things ... Do you agree?

NPS WARNING: *external sender* verify before acting.


Hi Folks,

Consider this XML document:

<Items>
    <Aquarium>
        <Tank>40 gallon capacity</Tank>
    </Aquarium>
    <Abrams>
        <Tank>M-1A2C</Tank>
    </Abrams>
</Items>

Notice that there are two <Tank> elements. They have completely different meanings: the first is a tank that we put fish in, the second is a tank that is used in military battles.

Same tag name, totally different meanings.

Are you okay with that? That is, are you okay with using the same tag name for two different things?

Below I make this argument: Never use the same tag name for two different things.

Here's why:

Recall the DRY (Don't Repeat Yourself) principle. Consider an XML Schema for the above XML. Assume the type for the aquarium tank is different than the type for the military tank:

<xs:element name="Title" type="AquariumTankType"/> <xs:element name="Title" type="MilitaryTankType"/>

The DRY principle says: Declare once, ref often. That is, in the XML Schema globally declare the Title element once and ref to it multiple times. But we can't declare Title only once since they have different types. There must be at least one Title element that is locally declared. The DRY principle must be violated. That is bad design.

Question: Beside violating the DRY principle, are there other reasons to avoid using the same tag name for different things?

Here's a better design:

<Items>
    <Aquarium>
        <Tank>40 gallon capacity</Tank>
    </Aquarium>
    <Abrams>
        <BattleTank>M-1A2C</BattleTank>
    </Abrams>
</Items>

Now an XML Schema can declare Tank and BattleTank globally and ref to them. DRY is intact.

Question: do you agree that XML documents should not use the same tag name for different things?

/Roger


_______________________________________________________________________

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: https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.oasis-open.org%2Fmlmanage%2F&amp;data=04%7C01%7Cbrutzman%40nps.edu%7C2bfd232298e34fe5991508d9db7ced7d%7C6d936231a51740ea9199f7578963378e%7C0%7C0%7C637782151879417286%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=UB%2BDVGtAhyUEqnOjs7Ol5jIwZY6SyNUisdEiUR6F%2BAQ%3D&amp;reserved=0
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org List archive: https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.xml.org%2Farchives%2Fxml-dev%2F&amp;data=04%7C01%7Cbrutzman%40nps.edu%7C2bfd232298e34fe5991508d9db7ced7d%7C6d936231a51740ea9199f7578963378e%7C0%7C0%7C637782151879417286%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=aNSoe%2FT1M2jwQ87WghqLhkvK7DI76vwGrsQjgguA9P0%3D&amp;reserved=0
List Guidelines: https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.oasis-open.org%2Fmaillists%2Fguidelines.php&amp;data=04%7C01%7Cbrutzman%40nps.edu%7C2bfd232298e34fe5991508d9db7ced7d%7C6d936231a51740ea9199f7578963378e%7C0%7C0%7C637782151879417286%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=tlcQVSMr5Y9CMzeq3f1XW5h1QJPsg1cR%2BTAe%2BFun%2F1g%3D&amp;reserved=0



[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