XML Namespaces and Unprefixed Attributes

drillwifey

New Member
The specification of XML Namespaces explains that the interpretation of unprefixed attributes is determined by the element on which they appear. And that the namespace name for an unprefixed attribute name always has no value.How does this rule apply to the namespace of the attribute \[code\]jid\[/code\] in the following cases.\[code\]<query xmlns="jabber:iq:roster"> <item jid="[email protected]"></item></query>\[/code\]If the declaration of the namespace and the attribute in question both don't have an prefix, the attribute \[code\]jid\[/code\] is in the namespace \[code\]jabber:iq:roster\[/code\].\[code\]<q:query xmlns:q="jabber:iq:roster"> <q:item q:jid="[email protected]"></q:item></q:query>\[/code\]If both, the declaration of the namespace and the attribute have the same prefix, the attribute \[code\]jid\[/code\]also has the namespace \[code\]jabber:iq:roster\[/code\]:\[code\]<q:query xmlns:q="jabber:iq:roster"> <q:item jid="[email protected]"></q:item></q:query>\[/code\]But in which namespace is the attribute if the namespace is declared with an prefix but the attribute doesn't have a prefix? I would assume, that the attribute \[code\]jid\[/code\][*]has the default namespace declared in a parent element,\[code\]<parent xmlns="http://example.com"> <q:query xmlns:q="jabber:iq:roster"> <q:item jid="[email protected]"></q:item> </q:query></parent>\[/code\][*]or no namespace, if there isn't such a declaration.Do I get this right?
 
Back
Top