Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

schema defaultNamespace or targetNamespace?  RSS feed

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

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

In the below example the default namespace is 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="" xmlns="" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Employee">
<xs:documentation>Comment describing your root element</xs:documentation>
<xs:element name="Name">
<xs:restriction base="xs:string">
<xs:maxLength value="10"/>
<xs:element ref="Adress"/>
<xs:element name="Adress">
<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"/>

Thanks in advance.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!