[jdom-interest] help needed for XML schema and it validation process

Miguel Angel Medina Lopez mamedina at logic-factory.com
Wed Nov 21 03:48:15 PST 2001


Hi:
This is the process for validation with JDOM and XMLSchema.
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 next 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: "Li, Wesley" <wesley.li at wcg.com>
To: "'Alex Rosen'" <arosen at silverstream.com>; "'Sébastien Pierre'"
<spierre at isb-sib.ch>; "'Paul Libbrecht'" <paul at ags.uni-sb.de>
Cc: <jdom-interest at jdom.org>
Sent: Tuesday, November 20, 2001 6:05 PM
Subject: [jdom-interest] help needed for XML schema and it validation
process


> I am new to the validation with Java and XML schema, and need assistant to
> write a parser program.
> Given a schema file such as Foo.xsd, as well as an instant xml file
Foo.xml,
> does anybody have a code example to show me how the validation process
> works? I know how to use JDOM to validation of the DTD against its xml
> document, but don't know how to do it with W3C XML schema.
>
> Thanks a lot,
>
> Wesley
> _______________________________________________
> 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