Firstly, it you're going to do it as name-value pairs, I would definitely add an enclosing element: <NameValuePair> <Name>xx</Name> <Value>vv</Value> </NameValuePair> because that makes processing much easier using almost any XML technology (whether XPath, data binding, or whatever). I would probably use attributes rather than child elements, but that's a pretty low-level difference. You're right, of course, that at one level this is technical nonsense: XML is already extensible at the level of element names, so what does this additional layer of extensibility add? In practice, though, systems impose rules on the element name vocabulary, whether through schemas, data binding, or whatever, that make it difficult to exploit XML's intrinsic flexibility to add new elements. So changing the vocabulary at the level of element names isn't always as easy as it might be, which is why people feel a need to add another layer. I remember being taught as a student (by Roger Needham, I think) that most problems in computing can be solved by adding another level of indirection. Michael Kay Saxonica
|