W3C home > Mailing lists > Public > xml-dist-app@w3.org > December 2001

RE: NameValue and NameValueList data types

From: Noah Mendelsohn <noah_mendelsohn@us.ibm.com>
Date: Thu, 20 Dec 2001 22:42:57 -0500
To: "Mike Dierken <mike" <mike@dataconcert.com>
Cc: "jacek" <jacek@systinet.com>, "xml-dist-app" <xml-dist-app@w3.org>
Message-ID: <OF416A11FE.4B9D8A22-ON85256B29.0014ADA0@pok.ibm.com>

Mike Dierken asks:

>> In XML, it's natural to do:

>>    <name-of-map>
 >>      <name>value</name>
 >>      <name>value</name>
>>    </name-of-map>

>> Is that how they do it?

I don't know if anyone does it this way, but there can be problems.  This
is a natural and useful solution in the case where the keys happen to be
comprised of legal XML name characters.  In other cases, there are common
characters which are not allowed, and it surely does not work for binary.

This is a common trap that often comes up when XML is used, even for
purposes as simple as dumping simple programming language structures.  If
you have non-name characters, you have to do something about it.  There is
indeed a proposal for escaping such characters in the names...it works, and
is probably OK for automatically generated files.  For human readability,
it's less convenient.  I would think that:

<name-of-map>
 <mapentry key="keyvalue">value</mapentry>
 <mapentry key="keyvalue2">value2</mapentry>
</name-of-map>

would be a better compromise in terms of robustness and readability.   Of
course, there are many variations on this theme including:

<name-of-map>
 <mapentry>
   <key>keyvalue</key>
   <value>value</value>
  </mapentry>
 <mapentry>
   <key>keyvalue2</key>
   <value>value2</value>
  </mapentry>
</name-of-map>

This is more verbose, but it allows yet richer keys such as binary:

<name-of-map>
 <mapentry>
   <key xsi:type="xsd:base64Binary>..</key>
   <value>value</value>
  </mapentry>
</name-of-map>

I think any of these are likely to be more robust than coding the key as
the element name.  That said, using the element name is indeed convenient
in the limited cases where it works.

------------------------------------------------------------------------
Noah Mendelsohn                                    Voice: 1-617-693-4036
Lotus Development Corp.                            Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------------
Received on Thursday, 20 December 2001 22:54:44 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 22:28:13 UTC