On 10/18/2012 2:11 AM, Ludovic Kuty wrote:
> I like to know things precisely but your paragraph which begins with "As
> far as "clearly" goes" invites me to put things in perspective and focus
> more on the how-to-do-things that on the what-things-are-made-of. As a
> teacher, I also want to be clear on the topic but I don't want to lose
> my students following that path. Lots of examples should clarify the
> matter for them.
Sounds good. Formalisms are great for the times when rigor is required
(eg when you're implementing what's being described and need to be
Absolutely Sure yours behaves like everyone else's), but practical
examples and general intuitive definitions are fine for everyday use.
For your students, I'd avoid the term "qualified name" entirely. They're
just names. Some names have prefixes, which associate them with specific
namespaces. (You can think of the prefixed name as shorthand for a
longer name that includes the namespace URI, though that expanded syntax
was rarely used except when discussing the behavior of code -- which may
be a pity.) Other names don't have prefixes, and either the name stands
by itself or was associated with the namespace using the
default-namespace (xmlns=) mechanism, which is "a shorthand for the
shorthand".
Important point which folks tend to miss: The default namespace
definition DOES NOT AFFECT ATTRIBUTES. If the aren't prefixed, they
aren't associated with any namespace, period. That's often entirely
acceptable since the namespaced element they appear in provides
context... but it's something to be aware of when working with these
documents.
Another important point: If you're using the DOM, the old "level 1"
non-namespace-aware methods for creating elements and attributes are NOT
compatible with namespace aware "level 2" processing. The former should
be considered deprecated except when interfacing with ancient
level-1-only DOM applications. See the W3C's DOM FAQ for a few more
words on that topic. (I fought hard to find a way to avoid that
compatibility break, and failing that to officially deprecate the old
calls... but the W3C didn't have a deprecation mechanism and other folks
weren't comfortable trying to write the deprecation more clearly into
the spec since Level 1 is officially still supported.)
There are ways this all could be made clearer if we had designed XML
completely before releasing it. But then it wouldn't have gotten the
early adopters and the traction needed to establish itself in the
industry. Maybe someday there'll be an XML 2.0 where we can rewrite
everything into coherent form -- define the infoset first with
namespaces and schemas and such fully incorporated into that document,
then define the syntax and APIs and tools on top of that. For now, we
have to live with afterthoughts and looking at multiple documents to
resolve what should be simple questions.
One more afterthought: If you're interested in why XML is as it is, I
*highly* recommend the Annotated XML Recommendation website. It
clarifies what the authors of XML 1.0.0 intended some of the more
obscure phrases to mean, why they made the decisions they did, and
generally puts the whole thing into much clearer context. It's a pity
nobody had the time or energy to do that to later revisions and/or to
the other standards.