• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Namespace Declaration !!

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Giving this schema I have two questions.
Is it mandatory to declare a qualified name mh:USAddress in the element shipAddress and USAddress of PurchaseOrder??
If I declare only type="USAddress" the schema does take the targetNamespace?

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:mh="http://www.Monson-Haefel.com/jwsbook"
targetNamespace="http://www.Monson-Haefel.com/jwsbook" >

<complexType name="PurchaseOrder">

<sequence>
<element name="accountName" type="string" />
<element name="accountNumber" type="unsignedShort" />
<element name="shipAddress" type="mh:USAddress" />
<element name="billAddress" type="mh:USAddress" />
<element name="book" type="mh:Book" />
<element name="total" type="float" />
</sequence>

<attribute name="orderDate" type="date"/>

</complexType>

<complexType name="USAddress">
<sequence>
<element name="name" type="string" />
<element name="street" type="string" />
<element name="city" type="string" />
<element name="state" type="string" />
<element name="zip" type="string" />
</sequence>
</complexType>

<complexType name="Book">
<sequence>
<element name="title" type="string" />
<element name="quantity" type="unsignedShort" />
<element name="wholesale-price" type="float" />
</sequence>
</complexType>

</schema>

Thanks
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if you derive an instance document from this schema and try to validate it against both alternatives of the schema ?
[ October 11, 2006: Message edited by: Valentin Crettaz ]
 
Marco Lombardo
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please, explain better.
Is it legal to omit mh:?
Thanks.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the delay, Marco !

No, you have to put that prefix there otherwise the parser will not be able to find the USAddress type. The targetNamespace property only indicates in which namespace the newly defined types (PurchaseOrder, USAddress, Book) will be located. Thus, in order to use one of those types (as attribute or element type) you have to tell in which namespace to find it, and this is done by using the namespace prefix.

If you don't include the prefix, the element will be searched for in the default namespace (the one defined by xmlns="") and in this case it is the XML Schema namespace. The parser will not be able to find the USAddress element in the XML Schema namespace.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic