Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Cannot validate xml file with schema

cstaprogrammer (Programmer) (OP)
29 Jan 09 13:34
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="http://localhost"
xmlns:xsi="http://localhost"
xsi:schemaLocation="http://localhost 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="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" 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
 
tsuji (TechnicalUser)
30 Jan 09 0:21
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

<metaData
xmlns="http://localhost"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://localhost 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>

[2] xsd document

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost" xmlns="http://localhost" 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>

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close