XML Schema problem.

Status
Not open for further replies.

Tychom

Ars Tribunus Militum
2,391
Subscriptor
I'm trying to validate an xml document against a schema, both of these come from the examples at w3schools. I've modified this particular example because i think its wrong anyway but here is what i have:

xml file:
******
Validating XML file books2.xml

Validation error: The 'note' element is not declared. An error occurred at file:///D:/website/books2.xml(2, 2).

Validation error: The 'to' element is not declared. An error occurred at file:///D:/website/books2.xml(6, 4).

Validation error: The 'from' element is not declared. An error occurred at file:///D:/website/books2.xml(7, 4).

Validation error: The 'heading' element is not declared. An error occurred at file:///D:/website/books2.xml(8, 4).

Validation error: The 'body' element is not declared. An error occurred at file:///D:/website/books2.xml(9, 4).
Validation finished. Validation failed.

Now, i see no errors in the xsd file, it matches examples I've seen on xml.com and obviously w3schools, i've also found that with microsofts examples they also fail when a schema is pointed to using xsi:schemaLocation (it defaults to using the schema as a namespace which IMO does nothing), does anyone see whats going wrong? (its starting to get annoying :( )

If the schema is embedded into the xml file then everything works fine:
code:<HR>
Code:
<?xml version="1.0" encoding="UTF-8"?><P><notes>
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="note">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="to" type="xs:string"/>
          <xs:element name="from" type="xs:string"/>
          <xs:element name="heading" type="xs:string"/>
          <xs:element name="body" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </xs:schema><P>  <note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
  </note>
</notes>

:mad:
 
Status
Not open for further replies.