[jdom-interest] JDOM problems...

John Nikolai jnikolai at is2inc.com
Mon Sep 17 14:36:42 PDT 2001

Hello everyone!

I'm having a problem with the JDOM parser and I could use some help. Below 
is an XHTML document, some simple java code that parses that XHTML file and 
dumps it out the output stream, and finally an example output from the java 

The problem is that the output attaches a new attribute to the "a" element, 
called "shape" with a value of "rect". Where is this coming from? I know 
that "shape" is an attribute of the anchor tag but why is it being added to 
the element?

When I take the "DOCTYPE" element out of the XHTML document the output is 
correct. I have tried all the DTD's available from www.w3.org and all cause 
the similar problem. Sorry for my ignorance but I may be missing something 
obvious here. =P

Thank you for your help,
   - John

------------- XHTML document (test.html) -------

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


		<a href=""> </a>


------------- Java code (Test.java) ------------
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;

import org.jdom.*;
import org.jdom.input.DOMBuilder;
import org.jdom.output.XMLOutputter;

public class Test {

     public static void main (String args[]) {

         try {
             DOMBuilder builder = new DOMBuilder(false);

             File file = new File("test.html");
             Document doc = builder.build(file);

             XMLOutputter out = new XMLOutputter();
             System.out.println("output = \n" + out.outputString(doc));

         } catch (Exception e) {

} // END Test


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 


		<a href="" shape="rect"> </a>


More information about the jdom-interest mailing list