Validating an XML file

U

usenet

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)
=============================================
 
G

Guest

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. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top