• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

About targetNamespace

 
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.
 
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.
 
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 ]
 
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
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic