[jdom-interest] adding default attributes

Christian Knorr christian.knorr at gmx.de
Thu Jul 19 00:28:11 PDT 2001


Hi,

I am looking for a convenient way to add default attribute values (like
the following in DTD: 
<!ATTLIST Frameset Orientation (horizontral | vertical ) 'vertical' >
) to a JDOM-tree like SAXBuilder does when reading the document from a
file. 

I tried to serialize the document to a string and read it again with
SAXBuilder, but in this case the default attributes are not
automatically added when reading. 

My test code is the following: 

      XMLOutputter xo = new XMLOutputter();
      StringWriter sw = new StringWriter();
      xo.output(doc, sw);
      SAXBuilder sb = new SAXBuilder();
      sb.setValidation(true);
      doc = sb.build(new StringReader(sw.toString()));

The DTD is definitly used for validation but not for adding default
attribute values. Is this a bug or is there another way to accomplish
this?

Christian



More information about the jdom-interest mailing list