xml - Why is there no prefix associated with this xmlns? -


i'm playing around xmpp , learning xml. here example of element retrieve registered users xmpp docs:

 <iq from='bard@shakespeare.lit/globe'         id='get-registered-users-num-1'         to='shakespeare.lit'         type='set'         xml:lang='en'>       <command xmlns='http://jabber.org/protocol/commands'                 action='execute'                node='http://jabber.org/protocol/admin#get-registered-users-num'/>     </iq> 

why there no prefix before xmlns namespace? why not:

<command xmlns=get_users:'http://jabber.org/protocol/commands'                 action='execute'                node='http://jabber.org/protocol/admin#get-registered-users-num'/> 

does mean it's defining namespace 1 child element <command> only? if so, why that?

this referred 'default' namespace. it, essentially, prefixes attributes (and elements) of element declared on namespace (which, in case http://jabber.org/protocol/commands), making equivalent this:

<command xmlns:default_namespace="http://jabber.org/protocol/commands"        default_namespace:action="execute"        default_namespace:node="http://jabber.org/protocol/admin#get-registered-users-num" /> 

if have children of node, have same default namespace prefixed them automatically (unless had different default namespace).

it's pretty handy if you're dealing 1 namespace, things can go out of hand rather fast if you're dealing multiples.

xpath can have issues default namespaces well, if using parse xml, beware!


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -