Squirm
Well-known member
So Ive written my XML schema. VS likes it, and the xsd tool creates nice serializable classes, so the schema must be ok. I have called my namespace urn:xmlns:toffee like so:
Now I want to test the schema in Sample.xml, so I started with this:
userfile is the document/root element defined in the schema, and the code generated by xsd reflects that. However, the code above causes the following error when I open the xml file in VS:
Changing the xmlns attribute of the userfile tag to "Toffee.xsd" causes the XML file to load without error, but intellisense for the document is incorrect since Toffee.xsd is not a namespace, just a filename. Do I really have to use the name of the xsd file as the namespace name?
Argh! Its frustrating. All I want to do is have a namespace called urn:xmlns:toffee defined in the schema Toffee.xsd and have it referenced in Sample.xml such that I dont have to prefix every tag with toffee:
Ive read and reread all the tutorials I could find on XML schemas, and I just dont get it.
Thanks for reading.
Code:
<xs:schema id="Toffee" targetNamespace="urn:xmlns:toffee" elementFormDefault="qualified" xmlns="urn:xmlns:toffee" xmlns:xs="http://www.w3.org/2001/XMLSchema">
....
</xs:schema>
Now I want to test the schema in Sample.xml, so I started with this:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<userfile xmlns="urn:xmlns:toffee" xmlns:toffee="urn:xmlns:toffee" toffee:schemaLocation="Toffee.xsd">
....
</userfile>
userfile is the document/root element defined in the schema, and the code generated by xsd reflects that. However, the code above causes the following error when I open the xml file in VS:
Loading the target schema failed because the file {0} does not exist.
Continue to load data without the referenced schema?
(Despite the yes/no question the only buttons provided are OK and Help!)
Changing the xmlns attribute of the userfile tag to "Toffee.xsd" causes the XML file to load without error, but intellisense for the document is incorrect since Toffee.xsd is not a namespace, just a filename. Do I really have to use the name of the xsd file as the namespace name?
Argh! Its frustrating. All I want to do is have a namespace called urn:xmlns:toffee defined in the schema Toffee.xsd and have it referenced in Sample.xml such that I dont have to prefix every tag with toffee:
Ive read and reread all the tutorials I could find on XML schemas, and I just dont get it.
Thanks for reading.