[Ietf-caldav] hyphens in element names problematic
for XML language bindings
dmose at mozilla.org
Tue Feb 1 13:24:23 PST 2005
Helge Hess wrote:
> On 29. Jan 2005, at 00:38 Uhr, Dan Mosedale wrote:
>> In my mind, the issue is not a matter of optimization, but of
>> readable code.
> But isn't that the same reason why dashes are used in the protocol?
> XML is supposed to be human readable/writable for various reasons and
> slashes help with that.
Fair enough. However, I suspect we can come up with a list of elements
names for the caldav context that are similarly readable to our current
set, which is really what counts here, I think.
>> My experience has been that less readable code tends to have more
>> bugs. As you point out, it's too late to fix existing cases of this
>> in WebDAV itself, but by changing the new CalDAV-specific elements,
>> we can at least avoid making the problem worse. If we do this, then
>> implementors end up having fewer code statements that need to use
>> hard-to-read escape syntaxes. This should lead, I suspect, to at
>> least slightly less buggy code in the CalDAV implementations written
>> in such environments, which is good for the community as a whole.
> It makes it easier for your specific implementation of the XML parser
> which may or may not be a worthwhile reason (IMHO its not).
> Personally I would assume that your XML parser could be easily
> enhanced to escape dashes with eg underlines prior calling back to the
> application? Since dashes are regular XML, I would assume that this
> should be in the parser anyway?
I think you're misunderstanding the concept of a native-language
binding: the parsing for XML element names can't be separate from the
language parsing itself. That is, XML element names are parsed as
member variable names in the context of normal code. So in JS, for
example, this means that XML element names that are compatible with JS
property names can be addressed directly as a property on a JS object,
but names with (eg) a minus in them cannot. This is likely to be true
of any native XML binding to almost any language: minus is an operator
(and therefore not part of a valid variable name) in most popular
Having the language binding use an underscore instead can't work,
because underscore is also valid in XML element names, so there would be
no way to disambiguate.
More information about the Ietf-caldav