Validating an XML file

  • Thread starter Thread starter Jack White
  • Start date Start date
I wish I could say it worked for me.

This still isn't working for me.

Here's my XML file ("details.xml"):
<?xml version="1.0" encoding="UTF-8" ?>
<details/>

Here's my XSD file ("Test.xsd")
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Test" targetNamespace="http://tempuri.org/Test.xsd"
elementFormDefault="qualified" xmlns="http://tempuri.org/Test.xsd"
xmlns:mstns="http://tempuri.org/Test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="details" type="xs:string" />
</xs:schema>

I haven't checked all of this thread, so apologies if I've missed the
intended point. But your XML instance isn't valid against your
schema. Either the XML instance needs to be (i.e. add in namespace
declaration):

<?xml version="1.0" encoding="UTF-8" ?>
<details xmlns="http://tempuri.org/Test.xsd"/>

Or your schema needs to be (i.e. remove targetNamespace etc.):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Test"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="details" type="xs:string" />
</xs:schema>

HTH,

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================
 
I was so focused on finding out what was wrong with the code that I neglected
to consider something was wrong with the schema. That, plus I'm not really a
schema guy. I used Visual Studio to visually create the schema, so I just
assumed it was right. Thanks for setting me straight. :)
 
Back
Top