Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot validate xml file with schema

Status
Not open for further replies.

cstaprogrammer

Programmer
Apr 20, 2005
11
GB
Hello

I am really new to xml and really struggling with getting started validating my test xml file with a schema. I have a web server running on my local machine with the schema in the root directory of my web server folder.

Here is my xml file:
<metaData
xmlns="xmlns:xsi="xsi:schemaLocation=" tserverschema.xsd">

<cfgApplication type="1" version="7.6.000.40" templateVersion="8.0.000.00">
<description>
Here the Application description located, where the roles and base functionality described.
</description>
<installation>
</installation>
</cfgApplication>
</metaData>


And here is my schema:
<?xml version="1.0"?>

<xs:schema xmlns:xs=" targetNamespace=" xmlns=" elementFormDefault="qualified">

<xs:element name="metaData">
<xs:complexType>
<xs:sequence>
<xs:element name="cfgApplication" type="xs:string"/>
<xs:attribute name="type" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="version" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="templateVersion" type="xs:string" use="required"></xs:attribute>
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string"/>
<xs:element name="configuration" type="xs:string"/>
<xs:element name="linkedResources" type="xs:string"/>
<xs:element name="installation" type="xs:string"/>
</xs:sequence>
</xs:complexType>

<xs:element name="cfgDN" type="xs:string"/>
<xs:element name="cfgAgentLogin" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element></xs:schema>

In Altova XMLSpy I get the error message that xml file is not valid. Unable to locate a reference to a supported schema type (DTD, W3C Schema) within this document instance.

What am I doing wrong?

Angus
 
It is not that easy: wrong at many places. This is a minimal rewrite and every modification is not frivole. If it looks not immediately clear to you, I suggest you've to "re-discover" all the differences I have made to your documents and get an idea why.

[1] xml doc
[tt]
<metaData
xmlns="[ignore][/ignore]"
xmlns:xsi="[ignore][/ignore]"
xsi:schemaLocation="[ignore] tserverschema.xsd[/ignore]">
<cfgApplication type="1" version="7.6.000.40" templateVersion="8.0.000.00">
<description>
Here the Application description located, where the roles and base functionality described.
</description>
<installation>
</installation>
</cfgApplication>
</metaData>
[/tt]
[2] xsd document
[tt]
<?xml version="1.0"?>
<xs:schema xmlns:xs="[ignore][/ignore]" targetNamespace="[ignore][/ignore]" xmlns="[ignore][/ignore]" elementFormDefault="qualified">
<xs:element name="metaData">
<xs:complexType>
<xs:sequence>
<xs:element name="cfgApplication">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string"/>
<xs:element name="configuration" type="xs:string" minOccurs="0" />
<xs:element name="linkedResources" type="xs:string" minOccurs="0" />
<xs:element name="installation" type="xs:string"/>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="version" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="templateVersion" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="cfgDN" type="xs:string" minOccurs="0" />
<xs:element name="cfgAgentLogin" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top