[jdom-interest] adding default attributes
Szegedi, Attila
szegedi at scriptum.hu
Thu Jul 19 02:30:21 PDT 2001
Documentation for SAX2 ContentHandler.startElement() method states that
"Note that the attribute list provided will contain only attributes with
explicit values (specified or defaulted): #IMPLIED attributes will be
omitted."
This clearly means that if there is a DTD, defaulted attributes should
appear, otherwise it is a bug.
Attila.
> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Christian Knorr
> Sent: Thursday, July 19, 2001 9:28 AM
> To: jdom-interest
> Subject: [jdom-interest] adding default attributes
>
>
> 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
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com
More information about the jdom-interest
mailing list