Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] Validating with SAXBuilder

Kostas Karadamoglou

2005-08-10

Replies:

Hi again!

I am trying to validate a xml file that does not have schema reference.
The header of the xml file is the following:

<?xml version="1.0" encoding="UTF-8"?>

<irisCacheDB xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
  <database dbID="Northwind">
     <table tableID="Customers">
...

I initialize the builder object the following way:

     try{
        URL schema =
CacheContext.class.getResource("/essex/kkarad/cache/model/IrisSchema.xsd");
        SAXBuilder builder=new SAXBuilder(true);

builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",schema.toString());
        Document doc=builder.build(this.confFile);
     }catch(Exception ex){
        ex.printStackTrace();
     }

Unfortunately the builder object returns an Exception:

org.jdom.input.JDOMParseException: Error on line 3 of document
file:/C:/Development/Projects/CC401/IrisCacheServer/iris.xml: Document
is invalid: no grammar found.
     at org.jdom.input.SAXBuilder.build (SAXBuilder.java:465)
...

How can I solve this problem? How can I made SAXBuilder validate the xml?

thank you in advance, Kostas

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.