- From: Pete Hendry <peter.hendry@capeclear.com>
- Date: Fri, 21 Dec 2001 12:56:05 +0000
- To: Noah Mendelsohn <noah_mendelsohn@us.ibm.com>
- CC: "Mike Dierken <mike" <mike@dataconcert.com>, jacek <jacek@systinet.com>, xml-dist-app <xml-dist-app@w3.org>
Again the focus here is on Map, but KeyValue has more uses than that so mapentry is not general enough. I would tend to go with the approach of having key and value as separate elements rather than use attributes for use with soap encoding. Pete Noah Mendelsohn wrote: > 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 Friday, 21 December 2001 07:58:05 UTC