472,989 Members | 2,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

Question about validating schema with xml file

Please give me your advice!

I made two files according to xml book, but when validating these two
files,
it gives me an error that I totally don't understand.

Is there a problem in these codes?

I checked xml and schema files through these following sites:
http://tools.decisionsoft.com/schemaValidate/
http://www.xmlme.com/Validator.aspx

XML file:
<?xml version="1.0" encoding="utf-8"?>
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="kool" xsi:schemaLocation="test.xsd">
<number>89</number>
</document>

Schema file:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns="kool" targetNamespace="kool" xmlns:xsd="http://
www.w3.org/2001/XMLSchema">

<xsd:element name="document" type="documentType"/>

<xsd:complexType name="documentType">
<xsd:sequence>
<xsd:element name="number" type="CustomNumber"/>
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="CustomNumber">
<xsd:restriction base="xsd:integer">
<xsd:maxInclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Jul 2 '08 #1
3 3579
jh3an wrote:
Please give me your advice!

I made two files according to xml book, but when validating these two
files,
it gives me an error that I totally don't understand.
Well you will have to tell us the exact error message if you want help
on that.

<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="kool" xsi:schemaLocation="test.xsd">
schemaLocation takes pairs of namespaceURI schemaURI so you need
xsi:schemaLocation="kool test.xsd"
<xsd:schema xmlns="kool" targetNamespace="kool" xmlns:xsd="http://
www.w3.org/2001/XMLSchema">
Add
elementFormDefault="qualified"
to the xsd:schema element.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 2 '08 #2
Error message differs:
from http://www.xmlme.com/Validator.aspx :
Schema Error: System.Xml.Schema.XmlSchemaException: Expected schema
root. Make sure the root element is and the namespace is 'http://
www.w3.org/2001/XMLSchema' for an XSD schema or 'urn:schemas-microsoft-
com:xml-data' for an XDR schema. at
System.Xml.Schema.XmlSchemaCollection.SendValidati onEvent(XmlSchemaException
e) at System.Xml.Schema.XmlSchemaCollection.Add(String ns, XmlReader
reader, XmlResolver resolver) at
System.Xml.Schema.XmlSchemaCollection.Add(String ns, XmlReader reader)
at Validator.Button1_Click(Object sender, EventArgs e)
from http://tools.decisionsoft.com/schemaValidate/ :
Well Formed: VALID
Schema Validation: INVALID

The following errors were found:
TYPE LOC MESSAGE
Warning 3, 44 SchemaLocation: schemaLocation value = 'test.xsd' must
have even number of URI's.
Validation 4, 9 cvc-complex-type.2.4.a: Invalid content was found
starting with element 'number'. One of '{"":number}' is expected.
Jul 2 '08 #3
jh3an wrote:
Error message differs:
from http://www.xmlme.com/Validator.aspx :
Schema Error: System.Xml.Schema.XmlSchemaException: Expected schema
root. Make sure the root element is and the namespace is 'http://
www.w3.org/2001/XMLSchema' for an XSD schema or 'urn:schemas-microsoft-
com:xml-data' for an XDR schema. at
System.Xml.Schema.XmlSchemaCollection.SendValidati onEvent(XmlSchemaException
e) at System.Xml.Schema.XmlSchemaCollection.Add(String ns, XmlReader
reader, XmlResolver resolver) at
System.Xml.Schema.XmlSchemaCollection.Add(String ns, XmlReader reader)
at Validator.Button1_Click(Object sender, EventArgs e)
That sounds as if you have presented the wrong file as the schema.

from http://tools.decisionsoft.com/schemaValidate/ :
Well Formed: VALID
Schema Validation: INVALID

The following errors were found:
TYPE LOC MESSAGE
Warning 3, 44 SchemaLocation: schemaLocation value = 'test.xsd' must
have even number of URI's.
That is what I told you, the schemaLocation is a list of pairs of the
namespace URI and the schema URL.
Validation 4, 9 cvc-complex-type.2.4.a: Invalid content was found
starting with element 'number'. One of '{"":number}' is expected.
Yes, your schema needs elementFormDefault="qualified", as I already told
you.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 2 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Duncan Smith | last post by:
Hello All, Has anyone found a way to specify an xsd schema programatically when using the apache xerces xml processor? I know that the validation works fine as long as the xml instance document...
2
by: maddalimurali | last post by:
Hello all, My xml and schema file header are as follows. 1) cisGlobals.xsd. <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.talgov.com/cisGlobals"...
9
by: Leona | last post by:
Hello all, does anyone know of a tool, preferably free, preferably on linux, which will take an xml file and validate it against your own custom W3C XML Schema file (.xsd) ?? All help...
3
by: Uwe Kuhne | last post by:
I receive a XML file from a customer and want to use a schema for validating the XML file. What I don't know how to do is, that I want to continue processing this XML - file no matter if there is...
1
by: Christian | last post by:
Hi, I load an Xml-file "customers.xml" into a DataSet (works fine) but then how do I validate it against a schema (e.g. customers.xsd) ? my customers.xml: <?xml version="1.0"...
1
by: drb | last post by:
Hi, Newbie question #2 - hope that's OK! I'm trying to create a WSDL file using one or more XSD schema files. While WSDL.exe doesn't seem to support the XSD "import" function, if I include a...
0
by: First_step_to_xml | last post by:
Hi All, I am trying to take an xml file as input from user and update the sql database with this new data from the xml file. Before going to the step of updating the data in the database, i...
1
by: donnie.hale | last post by:
Question: What's the "canonical" way to import an existing XSD schema file into VS2005 in such a way that I can use standard C# object / property techniques to create content of that schema type...
5
by: William Johnston | last post by:
Hello, I get the following error when instanciating an XmlReader that performs validation: "The 'http://tenbase2.com/DVDTimestamps:schemaLocation' attribute is not declared." My beginning...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.