INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

*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

Jobs from Indeed

Cannot validate xml file with schema

Cannot validate xml file with schema

(OP)
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
 

RE: Cannot validate xml file with schema

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>

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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!

Resources

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