Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About targetNamespace

 
Steven Gao Song
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, everyone,

I am reading the book RMH. On page 36,
it says that targetNamespace attribute declares the XML namespace of all
new types explicitly created within the schema.
So, in its example, USAddress type is automatically assigned to targetNamespace.
Since USAddress is in targetNamespace automatically, why the schema element still assigns a prefix mh to USAddress as "mh:USAddress"?

Thank you.
 
Mike Pandey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is done to re-use the type declared elsewhere. Either for the top-level element or as local elements of some other complex types to be defined.
 
Maddy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All namespaces need to be imported into an XML schema...The targetNamespace is no exception...Even though the target is "self" we still have to import it like any other namespace

So there are two ways to import a namespace, with and without prefix.

With Prefix
<schema targetNamespace="http://meme.com/namespace"
xmlns:mh="http://meme.com/namespace">

Here the prefix is mh:
Any element would be declared as
<attribute name="meme" type="mh:Meme"/>

Without prefix
<schema targetNamespace="http://meme.com/namespace"
xmlns="http://meme.com/namespace">

Here there is no prefix as "self" is assumed to be the default namespace
Any element would be declared as
<attribute name="meme" type="Meme"/>

Hope this helps
[ June 09, 2007: Message edited by: Maddy ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Maddy",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic