[jdom-interest] JDom and XMLSchema validation

jacqueline jacq at meterkast.dhs.org
Wed Oct 17 12:16:55 PDT 2001


On Wednesday 17 October 2001 12:46, you wrote:

You refer to the schema in your root element like this:
   
if your not using namespace:
<?xml version="1.0"?>
   <myrootelement 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="[path-to-schema]myschema.xsd"
   >
......

if your using namespace:
<?xml version="1.0"?>
   <mynamespace:myrootelement
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://your.own.uri.for.this.namespace"    //mynamespace here    
      xsi:schemaLocation="[path-to-schema]myschema.xsd"
   >
........

[pathtoschema] must be a valid uri.

I hope this will help you
Jacqueline

> Thank you jacqueline,
>
> One final question, how do you define the XMLSchema to use in the file.
> I have read a few books now that tell you how to decine the Schema, but
> not how to refer to it in the main file.
>
> Cheers
> Neil
>
> jacqueline wrote:
> > On Tuesday 16 October 2001 13:52, you wrote:
> >
> > Hi Neil,
> >
> > You can do this by creating a SAXBuilder or DOMbuilder and passing a
> > boolean to the constructor, for example:
> >
> >    // set validation on: pass true
> >    SAXBuilder builder = new SAXBuilder(true);
> >    Document doc = builder.build(String fileToParse);
> >
> > The schema named in the parsed document will be used.
> >
> > To get any validator output, you should implement
> > org.xml.sax.ErrorHandler or create something yourself.
> >
> > goodluck,
> > Jacqueline
> >
> >> Hello,
> >>
> >> I am trying to find out how to validate and XML file with an XMLSchema
> >> using JDOM. Please could anyone explain how to do this, possibly with a
> >> short example please.
> >>
> >> Cheers
> >> Neil
> >>
> >> _______________________________________________
> >> To control your jdom-interest membership:
> >> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@you
> >>rho st.com



More information about the jdom-interest mailing list