I\'m trying to understand how namespaces work in XML. When I have an element like foo:bar, the attributes will often not have namespaces on them. But sometimes they will. Ar
Read up at 6.1 Namespace Scoping and 6.2 Namespace Defaulting on w3c.
Basically:
The scope of a namespace declaration declaring a prefix extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag
However, the text here doesn't seem to explain if means a is foo:a or the default namespace in the context. I would assume that it does not refer to foo:a, but rather the documents default namespace a. Considering this quote at least:
Such a namespace declaration applies to all element and attribute names within its scope whose prefix matches that specified in the declaration.
Ie. the namespace "foo:" only applies to elements prefixed with foo: