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] Why does XML call them "attributes" and not name-value pairs?

+1

Thanks for this thorough explanation!

> So, regarding elements and attributes, vive la difference.  Might I offer a personal slogan, adapted from skateboard culture and in response to grossly archaic element-only XML:

 >        "Attributes are not a crime."

Excellent !

Personally,  I am trying to use whenever possible attributes over elements, due to a "minor", boring reason: attributes take much less space in memory (and in written form) than elements, and this can lead to significant memory footprint difference and performance difference for big documents.


Thanks,
Dimitre

On Sat, Jan 15, 2022 at 1:12 PM Brutzman, Donald (Don) (CIV) <brutzman@nps.edu> wrote:
(Oh cool, we can argue about preferences now!)

Best reference for precise terminology regarding elements and attributes in an XML context is unambiguous:

[1]     Extensible Markup Language (XML) 1.0 (Fifth Edition)
        W3C Recommendation 26 November 2008
        https://www.w3.org/TR/xml

n.b. elements, attributes
[1.1]   Section 3 Logical Structures
        https://www.w3.org/TR/xml/#sec-logical-struct

We've found that careful XML design (for document/data/object/information/whatever) that carefully integrates attributes with elements leads to clear representations that are simultaneously human readable and machine readable.  (No disrespect intended towards XML-unaware humans or machines...)

Deliberate design of attribute properties as part of each element, and then omitting attributes with default values, further assists with clarity and terseness.  I've found that documents designed as "elements only" can be much harder to read because of apparently endless sets of open-close elements; seems like too much text overhead spent on structure rather than information. YMMV.

Next, slight amount of compatible additional preprocessing (omitting defaults, sorting attributes, normalized values, regularized whitespace) as a canonical form makes valid XML documents strictly comparable (diffable), which subsequently enables XML Security capabilities for digital signature (authentication) and encryption (privacy).  In other words, if you have two XML documents with mismatched formats that contain identical information (as defined by Post-Schema Validation Infoset PSVI) then canonicalization can make them identical.

[2]     W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures
        W3C Recommendation 5 April 2012
        https://www.w3.org/TR/xmlschema11-1

n.b. PSVI
[2.1]   Section 2.1 Overview of XSD
        https://www.w3.org/TR/xmlschema11-1/#xsover

Next, if desired, lossless re-encoding by applying Efficient XML Interchange (EXI) leads to excellent compaction and high performance, among other merits.

[3]     Efficient XML Interchange (EXI) Format 1.0 (Second Edition)
        W3C Recommendation 11 February 2014
        https://www.w3.org/TR/exi

Of further note is that EXI and XML Security techniques can be used in combination if order of operations is sequenced carefully.  Thumbrule: first canonicalize, optionally sign, and then EXI-compress fragments before encryption (otherwise no meaningful compression occurs on pseudorandomized already-encrypted bits).  Once complete, can again digitally sign if you want visible outer signature.  Or, skip EXI completely and just use XML Security with your elements and attributes.

[4]     XML Technology: Security
        https://www.w3.org/standards/xml/security

Further adaptation of such designed XML elements/attributes as triples seems to work fine for RDF/OWL.  Haven't found any ambiguity when using Turtle syntax (which is not XML), agreed that corresponding equivalent RDF XML is best left to machine parsing.

[5]     RDF 1.1 Turtle, Terse RDF Triple Language
        W3C Recommendation 25 February 2014
        https://www.w3.org/TR/turtle

[6]     OWL 2 Web Ontology Language Document Overview (Second Edition)
        W3C Recommendation 11 December 2012
        Section 2.2 Syntaxes
        https://www.w3.org/TR/owl2-overview/#Syntaxes

So, regarding elements and attributes, vive la difference.  Might I offer a personal slogan, adapted from skateboard culture and in response to grossly archaic element-only XML:

        "Attributes are not a crime."

[7]     Wikipedia: Sting (percussion)
        https://en.wikipedia.org/wiki/Sting_(percussion)
        https://upload.wikimedia.org/wikipedia/commons/b/b4/Sting.ogg

Have fun with XML!   8)

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: Liam R. E. Quin <liam@fromoldbooks.org>
Sent: Saturday, January 15, 2022 11:31 AM
To: Roger L Costello <costello@mitre.org>; xml-dev@lists.xml.org
Subject: Re: [xml-dev] Why does XML call them "attributes" and not name-value pairs?

On Sat, 2022-01-15 at 12:42 +0000, Roger L Costello wrote:
> Hi Folks,
>
> Someone once told me:
>
>                Call it what it is.
>                Don't invent some artificial name.
>
> The items in yellow:
>
> <Person name="John Doe" employer="Acme Inc." age="30">...</Person>
>
> are name-value pairs.
>
> Why does XML call them "attributes"?

No yellow here. But, they are not name-value pairs, because they do not stand alone: they are associated with an element represented by start tag, content, and end tag. Instead, as others have pointed out, they represent attributes (properties) of that element.

Your example violates the principle expressed in B.1.2 of SGML, that attributes qualify the generic identifier. To put it another way, a good principle i've found in practice for documents is,
  Attributes are for computers. Element content is for humans.

Section "4.4.3 Attributes" describes attributes as analogous to declaring the type of a variable in a programming language.

So we could really have,
  <Person id="person301">
   <Name>Judith Doe</Name>
   <Employer type="14">Acme Inc.</Employer>
   <Age unit="years">30</Age>
   ...
  </Person>

Consider what happens if the person's name is in Traditional Chinese and the company name is Korean - now you need additional markup to identify the language and script, so it can be processed and displayed correctly - Unicode unification means you need to identify the different writing systems being used. You can't do that in attributes.

So attributes are supposed to be properties of the element name and the element itself, not of the thing represented.  That RDF has difficulty with this distinction doesn't mean we have to follow :-)

Liam

--
Liam Quin, https://www.delightfulcomputing.com
Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  https://www.fromoldbooks.org

_______________________________________________________________________

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.


_______________________________________________________________________

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



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.
 


[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