Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Question about validating schema with xml file

Reply
Thread Tools

Question about validating schema with xml file

 
 
jh3an
Guest
Posts: n/a
 
      07-02-2008
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 xmlnssi="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" xmlnssd="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>
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      07-02-2008
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 xmlnssi="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" xmlnssd="http://
> www.w3.org/2001/XMLSchema">


Add
elementFormDefault="qualified"
to the xsd:schema element.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
jh3an
Guest
Posts: n/a
 
      07-02-2008
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-
comml-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.
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      07-02-2008
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-
> comml-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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
Validating xml file against xml schema using javascript First_step_to_xml XML 0 06-28-2006 02:09 PM
Validating parsed XML document against XML-schema TKok Java 1 12-08-2005 02:01 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Validating XML against a DTD that is not supplied in the XML Schema Ben Jessel Java 0 08-05-2004 11:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57