Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in Schema  RSS feed

 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<schema xmlns="http://www.w3.org/2001/XMLSchema"

xmlns:mh="http://www.Monson-Haefel.com/jwsbook"
targetNamespace="http://www.Monson-Haefel.com/jwsbook">


I have understood the url specified in the xmlns and also the url specified in the targetNamespace,but i am not able to understand the
attribute xmlns:mh.

Can any body explain me what does it mean???


Thanks

Anil Kumar
[ March 14, 2008: Message edited by: anil kumar ]
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by anil kumar:
I have understood the url specified in the xmlns and also the url specified in the targetNamespace


Technically speaking they are URIs, not (necessarily) URLs - they identify something - they do not have to be a valid address.


i am not able to understand the attribute xmlns:mh


It isn't an attribute - it's a namespace declaration

xmlns:mh="http://www.Monson-Haefel.com/jwsbook"

means:

"I will refer to the {http://www.Monson-Haefel.com/jwsbook} namespace and will henceforth use the prefix 'mh' to refer to it"


targetNamespace declares the namespace into which you define your new elements, types and attributes - kind of like the Java "package" statement. Unlike Java's "package" though targetNamespace doesn't make that namespace the default namespace. If you want to use any of the elements, types and attributes that you have just defined (even to simply refer to them in the definition of other new elements, types, and attributes) you have to establish a way to refer to them by either making your targetNamespace the default namespace

xmlns="http://www.Monson-Haefel.com/jwsbook"

or assigning a prefix to it

xmlns:mh="http://www.Monson-Haefel.com/jwsbook"

See also namespace and targetnamespace
Confusion in namespace

Ronald Bourret's XML Namespaces FAQ
James Clark: XML Namespaces
 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Peer i have understood,but i have one more doubt.

xmlns:mh="http://www.Monson-Haefel.com/jwsbook"

in the above why do we have to use xmlns:mh??
can't we say mh="http://www.Monson-Haefel.com/jwsbook" ???


Please clarify this.

Thanks

Anil Kumar
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the above why do we have to use xmlns:mh?? can't we say mh="http://www.Monson-Haefel.com/jwsbook" ???


A namespace declaration always starts with "xmlns". That is the rule - end of story.
See 4.1) How do I declare an XML namespace in an XML document?

"xmlns=..." declares the default namespace; "xmlns:mh=..." declares a namespace that will be referenced inside the scope with the "mh" prefix.
 
anil kumar
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peer

Thank you ,I have got it




Thanks & Regards

Anil Kumar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!