Re: [xml-dev] Don’t create elements with simple content and attributes

From
Ihe Onwuka <>
To
"Costello, Roger L." <>
Date
2018-09-28T15:05:53Z
ID
<>
Thread
Re: [xml-dev] Don’t create elements with simple content and attributes

On Fri, Sep 28, 2018 at 10:49 AM Costello, Roger L. <[email protected]> wrote:

Hi Folks,

 

Thank you for the excellent replies.

 

Based on the replies, I see that I did a poor job explaining my position. Let me try again, please.

 

I am not arguing against attributes.

 

I am arguing against unlabeled data.

 

All of the following forms are good because they explicitly label the two pieces of data (USD and 8.95):

 

<Cost>
   
<Currency>USD</Currency>
   
<Amount>8.95</Amount>
</Cost> 

<Cost currency="USD" amount="8.95" />

<Cost currency="USD">
   
<Amount>8.95</Amount>
</Cost>

<Cost amount="8.95">
   
<Currency>USD</Currency>
</Cost>

 

It matters not whether the label is in the form of an attribute or an element.

 

I am arguing that the following is bad because one piece of data (8.95) is not explicitly labeled:

 

<Cost currency="USD">8.95</Cost>

 
Whereas by implication of what you have said you want to claim that 

<Cost>8.95</Cost>

is explicitly labeled.

So to flesh out your claim. Somehow the presence of the attribute on the Cost element interferes with what you are calling explicit labelling. 

Except that it doesn't.









 

 

You might argue that 8.95 is labeled and the label is Cost. I disagree. I argue that Cost applies to the entire element (including the currency attribute); it does not specifically apply to 8.95.

 

As a result of the absence of an explicit label for 8.95, it is impossible to convert that form to an element-only form without human intervention. For example, a couple days ago one human suggested that 8.95 be labeled with “Amount” like so:

 

<Cost>
   
<Currency>USD</Currency>
   
<Amount>8.95</Amount>
</Cost>

 

This need to get humans involved to convert to an element-only form is bad, I argue.

 

Comments?

 

/Roger