[jdom-interest] Validation with jdom?

Miguel Angel Medina Lopez mamedina at logic-factory.com
Mon Jun 25 00:28:02 PDT 2001


Hi:

 I validate xml document against schemas with JDOM. The next samples is with
beta6 and I don't know if work with beta 7.
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
Director de Proyectos
Logic Factory: www.logic-factory.com


----- Original Message -----
From: "Tony Zhang" <tjzhang at us.ibm.com>
To: <jdom-interest at jdom.org>
Sent: Friday, July 13, 2001 9:30 PM
Subject: [jdom-interest] Validation with jdom?


> Can any body give a hint to me regarding how to perform validation using
> jdom?
> I saw that there is a SAXBuilder class constructor which takes a boolean
> 'validate' and it gets passed to parse.setFeature method.  However, I
don't
> find where other features which present in xerces such 'schemaFullSupport'
> are handled. So my question is: can jdom perform a validation against a
> schema? If yes, how?
> Thank you.
>
> Tony
> 5600 Cottle Rd.  XIX/051 - 3A24, San Jose, CA 95193
> 408 256 7038 (o)   408 256 6214 FAX
>
> _______________________________________________
> 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