How to validate a XML Schema

S

Siddhartha Singh

Hi,
If XML can be validated by either DTD or Schema and Schema itself is a XML.
How can we validate a Schema ?
Cheers,
Siddhartha Singh
(e-mail address removed)
 
M

Martin Honnen

Siddhartha said:
Hi,
If XML can be validated by either DTD or Schema and Schema itself is a XML.
How can we validate a Schema ?

There is no complete XML Schema defining the XML schema however the
schema processors usually validate a schema when you load it. For
instance with MSXML 4 you can ask a schema to be validated when you add
it to the schema cache. Consider the following schema with a typo (type
mistyped as typ):

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="GOD" typ="xs:string" />

</xs:schema>

When you load that schema with MSXML e.g. with

var schemaCollection = new ActiveXObject('Msxml2.XMLSchemaCache.4.0');
schemaCollection.validateOnLoad = true;
try {
schemaCollection.add('', 'test20030815Xsd.xml');
}
catch (e) {
alert(e.description);
}

then an exception is caused an the alert shows that the attribute typ is
not supported.
 
M

Martin Honnen

Siddhartha said:
Hi Martin,
Thanks for your reply,
My question was regarding validation and not checking well formedness.
The example you have shown is giving the syntax error and not the
logical error in any schema.

The example schema is well-formed:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="GOD" typ="xs:string" />

</xs:schema>

However it doesn't validate and I have posted how you can check that
with MSXML 4.
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top