• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

About targetNamespace

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic