Solved

Unable to Validate XML using XML Validator, namespace problem?

  • 1 June 2018
  • 4 replies
  • 257 views

Badge

Hi Im having trouble validating some XML, I keep getting no declaration found for element Features errors.

heres the 1st part of the XSD 

<?xml version="1.0" ?>
<xs:schema id="Features" targetNamespace="urn:284_SeAr.xsd"  xmlns="urn:284_SeAr.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"  xmlns:sql="urn:schemas-microsoft-com:mapping-schema" xmlns:dt="urn:schemas-microsoft-com:datatypes"  attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="Sediment_Area"> 
<xs:complexType> 
<xs:sequence>...

And heres the start of my XML

<?xml version="1.0" encoding="UTF-8"?>
<Features>
<Sediment_Area>

it complains 

no declaration found for element 'Features'

But even if I remove the features element it still has similar errors all over the rest of it. After looking at some similar problems I am now suspecting this is something to do with the namespaces but even if I move them into my XML it doesn't seem to parse.

Is features actually declared by <xs:schema id="Features" ?

what do I have to do with the namespaces in the XSD in my XML.

Thanks for any help.

icon

Best answer by takashi 2 June 2018, 10:50

View original

4 replies

Userlevel 2
Badge +17

Hi @smurf,

  1. Since the XML Schema defines "targetNamespace", you will have to declare the namespace in any XML document, if you use elements/attributes defined in the schema.
  2. If you declare the namespace as the default namespace, every name from the schema can be used without namespace qualifier. Otherwise, you should add a declared qualifier to every element/attribute name derived from the schema.
  3. At least in the part of XML Schema you've posted, there is no definition for an element called "Features". An XML element name should be defined with "name" attribute of an <xs:element> element in the XML Schema, like the "Sediment_Area" element.

Badge

Hi @smurf,

  1. Since the XML Schema defines "targetNamespace", you will have to declare the namespace in any XML document, if you use elements/attributes defined in the schema.
  2. If you declare the namespace as the default namespace, every name from the schema can be used without namespace qualifier. Otherwise, you should add a declared qualifier to every element/attribute name derived from the schema.
  3. At least in the part of XML Schema you've posted, there is no definition for an element called "Features". An XML element name should be defined with "name" attribute of an <xs:element> element in the XML Schema, like the "Sediment_Area" element.

HI, thanks for the help, I have removed my features element and doing the validation before that now but I still just get the same error moved onto the sediment area element, (no definition...) I assume this is because I am not doing my namespace properly, where exactly do I add the namespace declaration and do I just have to add the target namespace or do I have to add all of the namespaces in the XSD?

 

 

I have tried

 

 

<?xml version="1.0" encoding="UTF-8"?>

 

<Sediment_Area Mission = "{fme:get-attribute("misnme")}" xmlns="urn:248_SeAr.xsd"

 

xmlns:xs="http://www.w3.org/2001/XMLSchema"

 

xmlns:sql="urn:schemas-microsoft-com:mapping-schema"

 

xmlns:dt="urn:schemas-microsoft-com:datatypes">

 

<Area_Feature>

 

 

I have tried

 

 

<?xml version="1.0" encoding="UTF-8"?>

 

<Sediment_Area Mission = "{fme:get-attribute("misnme")}" xmlns="urn:248_SeAr.xsd">

 

<Area_Feature>

 

 

It still complains there is no definition for sediment_area, Im sure my XML knowledge is lacking here, seems there is something I must be missing

 

 

 

 

Userlevel 2
Badge +17

Hi @smurf,

  1. Since the XML Schema defines "targetNamespace", you will have to declare the namespace in any XML document, if you use elements/attributes defined in the schema.
  2. If you declare the namespace as the default namespace, every name from the schema can be used without namespace qualifier. Otherwise, you should add a declared qualifier to every element/attribute name derived from the schema.
  3. At least in the part of XML Schema you've posted, there is no definition for an element called "Features". An XML element name should be defined with "name" attribute of an <xs:element> element in the XML Schema, like the "Sediment_Area" element.

typo?

 

  • Schema: targetNamespace="urn:284_SeAr.xsd"
  • Your default namespace declaration: xmlns="urn:248_SeAr.xsd"

 

 

Badge
typo?

 

  • Schema: targetNamespace="urn:284_SeAr.xsd"
  • Your default namespace declaration: xmlns="urn:248_SeAr.xsd"

 

 

Yeah I seem to have it working now, even with the features element still involved. Not sure how its now all working as I feel like I'm doing something I already tried! Thanks for the help

 

 

Reply