Link to home
Start Free TrialLog in
Avatar of pdegregorio
pdegregorio

asked on

XML validation error: Description: TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of ...

Hello,

The following error is reported in Oxygen XML but the parser does successfully validate my XML document against the given XSD:  "Description: TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://schemas/jupiter'."

Otherwise it appears to work. If I change noNamespaceSchemaLocation to schemaLocation the error changes to "There is no schema or DTD associated with the document" and the validation stops working. It appears that not using a namespace is not an option because the type used to validate the currency-short-name must be qualified with a namespace.

I would like this error to go away and ultimately have this properly defined.

Thank you,
Peter
Jupiter.xsd
 
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:jupiter="http://schemas/jupiter"
   targetNamespace="http://schemas/jupiter"
   elementFormDefault="unqualified" attributeFormDefault="unqualified">
   <simpleType name="currency-short-name-type">
      <restriction base="string">
         <enumeration value="EUR"/>
         <enumeration value="USD"/>
         <enumeration value="GBP"/>
         <enumeration value="CHF"/>
         <enumeration value="ON_EUR"/>
         <enumeration value="ON_GBP"/>
      </restriction>
   </simpleType>
   . . .
   <element name="estimate">
      <complexType>
         <sequence>
            <element name="estimate-currency" maxOccurs="unbounded">
               <complexType>
                  <sequence/>
                  <attribute name="name" type="string"/>
                  <attribute name="short-name" type="jupiter:currency-short-name-type"/>
                  <attribute name="exchange-rate" type="float"/>
               </complexType>
            </element>
    . . .
 
Sample.xml
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<jupiter:estimate name="XXX" description="X" rev-number="X"
    notice-to-proceed="2009-09-30" status="In Process" base-currency="EUR"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jupiter="http://schemas/jupiter" xsi:noNamespaceSchemaLocation="Jupiter.xsd"
    >
    <estimate-currency name="US Dollar" short-name="USD" exchange-rate="0.800000"/>
    <estimate-currency name="Euro" short-name="EURx" exchange-rate="1.000000"/>
 
Note: The above line correctly fails validation because EURx is not a valid currency-short-name-type

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdegregorio
pdegregorio

ASKER

Thank you, that worked! Does anything appear embarrassingly out of kilter that I should look at?
Welcome
Nothing embarrassing in this, it is a bit tricky anyway
It is the schema that decides whether you have a namespace or not in your XML
so if there is no targetnamespace in the schema use the reference as you did
if there is a target namespace, you need to reference that as well,
a bit perculiar, don't worry, now you know