Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Simple Namespace Question

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks very much for your help.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • 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
 
Good night. Drive safely. Here's a tiny ad for the road:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic