[jdom-interest] Nesting multiple levels of xml docs and using entity references.

Jeff Rasmussen jrasmussen at lnxi.com
Tue May 18 09:37:33 PDT 2004


Background:
I am trying to set up an interface to build documents in DocBook. I
would like to divide the xml files into sections based on the docbook
dtd. Ex. 

Set -->(contains) Book(one to many) -->(contains) Part(one to many)
-->(contains) Article(one to many)

I would like to separate these logical partitions into physical
partitions and place the files in separate directories. I will generate
dynamic header files(these contain the DocType) so I can export any
level of these documents on-the-fly without reading the entire document.

Problem:
When I try to read a document that has entity references but no DocType
I get a error "The entity ENTITY_REFERENCE_NAME was referenced, but not
declared.". I understand that it was not declared because I declare it
in a separate "header file" that references this file. Is there any way
to suppress this error and construct the document?

I have tried the following code:

this.expandEnitites = false;
this.validate = false;

SAXBuilder builder = new SAXBuilder();
builder.setExpandEntities(this.expandEnitites);
builder.setValidation(this.validate);
if(! this.validate){ 
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
builder.setEntityResolver(new NoOpEntityResolver());
}
Document document = builder.build(new File(fileHandle));


I am trying to read this XML file:

<?xml version="1.0" encoding="UTF-8"?>
<book>
  <title>Jeff</title>
  <bookinfo>
    <legalnotice>
      <para>No notice is required.</para>
    </legalnotice>
    <authorgroup>
      <author>
        <firstname>Jeff</firstname>
        <surname>Rasmussen</surname>
      </author>
    </authorgroup>
    <edition>First Edition</edition>
    <revhistory>
      <revision>
        <revnumber>1.0</revnumber>
        <date>Mon May 17 09:08:41 MST 2004</date>
        <authorinitials>
        </authorinitials>
        <revremark>Jeff</revremark>
      </revision>
    </revhistory>
  </bookinfo>
  &test;
</book>



Thanks for any available help!!!

Jeff Rasmussen




More information about the jdom-interest mailing list