[jdom-interest] missing baseURI in output

Larry Levin ljlevin at eclipse.net
Sat Dec 27 07:09:44 PST 2008


Hi:
I've been using JDom for quite some time with no probelems but just hit 
a snag when trying to create an OWL ontology using it. This issue is 
that while I set a baseURI for the document, it isnt showing up when the 
document is written using the XMLOutputer. The code is as follows:

      Namespace rdfsNs = Namespace.getNamespace("rdfs", 
"http://www.w3.org/2000/01/rdf-schema#");             Element root = new 
Element("RDF", rdfNs);
            :
          { add various namespaces to root }
            :
       Document doc = new Document(root);
       doc.setBaseURI("http://foo.bar/owlTest");

After building the document, I write it as follows:

       Format myFormat = Format.getPrettyFormat();
       XMLOutputter outputter = new XMLOutputter(myFormat);
       FileOutputStream fo =  new FileOutputStream(fileName);
       outputter.output(doc, fo);
       fo.flush();
       fo.close();

The  problem is that the xml base decalaration 
xml:base="http://foo.bar/owlTest" must explicitly appear in the output 
but doesnt. Any help would be greatly appreciated.
  Thanks
   Larry Levin


More information about the jdom-interest mailing list