• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Simple Namespace Question

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the two snippets, one is schema and the other is a XML document, shown below, why a new namespace "po" is created in the XML document? The URI for "po" is the same as that of "mh". Can we use "mh" in the XML document? Or can we not to create a namespace in the XML document? Thank you.



 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
The XML namespace prefix can be choosen as desired. It is just a convenient way that allows us to refer to a namespace without having to write the entire namespace string.
Best wishes!
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The prefix name you choose to use in the document should be equal to the targetnamespace of the schema which contains the element you are using.

for example, in your case, mh prefix is just for use in schema definition, but po prefix in document is actually linking to targetnamespace and not mh prefix. Its just that both prefix mh and targetnamespace are the same in this case.

so, you cannot use mh as it is defined for use only in the schema definition.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much for your help.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Day,

An interesting thing. The scope of the prefix extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag. Meaning, after passing the end tag the prefix is gone.
Please have a look at Namespace Scoping.

Regards,
Dan
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic