[jdom-interest] Schema Validation - How to ?

Miguel Angel Medina Lopez mamedina at logic-factory.com
Thu Nov 15 07:26:43 PST 2001


Hi:

You can locate Schema wherever you want and access it through a URL.
After you create a instante of SAXBuilder with validate to true, you must
indicate the schema in your XML file and the validation is automatic when
you call method buid of SAXBuilder object. You indicate the schema URL with
the nexy line at top of your XML document.

<?xml version="1.0"?>
<ROOT xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
                     xsi:noNamespaceSchemaLocation="schema_url_or_file.xsd">

If you create the document with the JDOM API methods, you must write the
next lines to include this attribute to the document:

        root = new Element("ROOT");
        root.addAttribute(new
Attribute("noNamespaceSchemaLocation","schema_url_or_file.xsd",Namespace.get
Namespace("xsi","http://www.w3.org/1999/XMLSchema-instance")));

        doc = new Document(root);

I hope this help you

-------------------------------------------------------------
Miguel Ángel Medina López
Logic Factory: www.logic-factory.com
Granada - España


----- Original Message -----
From: "Adrian Nolan" <adrnola at hotmail.com>
To: <jdom-interest at jdom.org>
Sent: Wednesday, November 14, 2001 5:38 PM
Subject: [jdom-interest] Schema Validation - How to ?


> Hi,
>
> To enable XML Schema validation with JDOM, I have set the validate to true
> when setting up the SAXBuilder, but it does not seem to be able to locate
> the XSD file ? Does the XSD file need to be in the JDOM directory or where
> should it be located ?
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>




More information about the jdom-interest mailing list