How to validate a XML Schema

Discussion in 'XML' started by Siddhartha Singh, Aug 15, 2003.

  1. 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
     
    Siddhartha Singh, Aug 15, 2003
    #1
    1. Advertising

  2. Siddhartha Singh wrote:
    > 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.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Aug 15, 2003
    #2
    1. Advertising

  3. Siddhartha Singh wrote:
    > 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.
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Aug 15, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,551
    Markus
    Nov 23, 2005
  2. Leona
    Replies:
    9
    Views:
    1,999
    Henry S. Thompson
    Nov 1, 2004
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,269
    Stanimir Stamenkov
    Apr 25, 2005
  4. Replies:
    3
    Views:
    2,875
  5. Stefan
    Replies:
    3
    Views:
    1,985
    Martin Honnen
    Mar 29, 2008
Loading...

Share This Page