Hacker News new | past | comments | ask | show | jobs | submit login

You seem to know a lot about the XML specification. More than your parent and certainly more than me. That's great, and following specifications is good and all, but citing the spec as requiring that "a namespace-aware XML parser must fault on undeclared namespaces" does not give me any sense for why I would want it to. Put another way - what does the namespace declaration and halting error due to its omission accomplish for me?

Failing to define a content type is obviously dumb, but I can't seem to get riled up about leaving off namespace declarations.




> That's great, and following specifications is good and all, but citing the spec as requiring that "a namespace-aware XML parser must fault on undeclared namespaces" does not give me any sense for why I would want it to.

That's not really relevant though. XML is bondage and discipline.

> Put another way - what does the namespace declaration and halting error due to its omission accomplish for me?

Depends. You could think "nothing" which is basically the same mindset as using a tagsoup-parser for "xml" documents: as long as you can get stuff out of it do you really care?

The other way to think about it, and the way espoused by most XML specs (and really most serialization specs at all) is that if something goes wrong, what guarantee is it anything is right? If a namespace prefix is undefined, is it because nobody cares, because there's a typo or because the unsafe transport flipped some bytes? The parser can't know, and as is generally done in the XML world the spec says to just stop and not risk fucking things up (as it does when nesting is invalid, attributes are unquoted or decoding blows up).

What that accomplishes is the assurance that the document was correct as far as an XML parser is concerned, I guess?

If you don't care, you're free to use a tagsoup parser in the first place, after all.

> I can't seem to get riled up about leaving off namespace declarations.

I see it more from a "canary in a coal mine" point of view: namespace declarations not being there hints that either they're using a non-namespace-aware serializer (unlikely) or they're not using an XML serializer at all, and here dragons lurk. In this case it's confirmed that they're pretty certainly using ERB text templates to generate their XML, and that means the document could be all kinds of fucked up with improper escaping, invalid characters and the like.

Meaning maybe the export can't be trusted to have exported my data without fucking it up.


A central idea of XML was that - in reaction to the mess that was HTML - any tool that calls itself XML MUST barf loudly on anything that is not XML, so that you could never have a situation where one tool is happily calling something XML and another tool barfs on it. (Because, given the choice, humans will regularly mess it up but not notice unless their tool tells them so, and what works for one tool won't for another.)

The requirement of strictness everywhere is a precondition for interoperability between diverse toolsets.


"... what does the namespace declaration and halting error due to its omission accomplish for me?"

It encourages generation of proper XML.

If consumers accept invalid XML, guessing at what it's supposed to mean, then producers will become sloppier over time, since there's no penalty for failing to follow the specification. Eventually producers will be so sloppy that producers will no longer be able to make meaningful guesses.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: