Win a copy of Transfer Learning for Natural Language Processing (MEAP) 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

schema defaultNamespace or targetNamespace?

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am confused with meaning of default namespace and targetNamespace in XML schema.

In the below example the default namespace is com.prashu.java.xml.jaxb and I have declared 2 elements Employee and Address. I have NOT provided the targetNamespace. The schema validation is failing when i try to refer the Address element from Employee, it is asking either define targetNamespace or remove defaultnamespace.

Can anyone please explain me the reason behind this?


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns="com.prashu.java.xml.jaxb" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Employee">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element ref="Adress"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Adress">
<xs:complexType>
<xs:sequence>
<xs:element name="Address1" type="xs:string"/>
<xs:element name="Address2" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
<xs:element name="PinCode" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks in advance.

Regards,
Prashant
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic