[jdom-interest] Validating with SAXBuilder

Kostas Karadamoglou karadamoglou_k at yahoo.gr
Wed Aug 10 11:06:02 PDT 2005


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



More information about the jdom-interest mailing list