[jdom-interest] XMLOutputter - setExpandEmptyElements(true) not functioningproperly.

Brett McLaughlin brett.mclaughlin at lutris.com
Tue Sep 19 17:30:10 PDT 2000


kendrick at us.ibm.com wrote:
> 
> I am seeing my empty elements (content of an empty String) outputted in the
> shorthand format (<tagName />) even after I issued
> setExpandEmptyElements(true).  I traced the code in XMLOutputter.
> printElement() to:
> 
>      ...
>      if (empty) {
>           // Simply close up
>           if (!expandEmptyElements) {
>                out.write(" />");
>           } else {
>                out.write("></");
>                out.write(element.getQualifiedName());
>                out.write(">");
>           }
>           maybePrintln(out);
>      } else if (stringOnly) {
>           // Print the tag  with String on same line
>           // Example: <tag name="value">content</tag>
>           // Also handle "" being added to content
>           String elementText = element.getText();
>           if ((elementText != null) && (!elementText.equals(""))) {
>                out.write(">");
>                out.write(escapeElementEntities(element.getText()));
>                out.write("</");
>                out.write(element.getQualifiedName());
>                out.write(">");
>           } else {
> ==========>
> == here ==>         out.write(" />");
> ==========>
>           }
>           maybePrintln(out);
>      } else {
>      ...
> 
> Apparently the check for expandEmptyElements needs to occur here as well.

Yup. Just fixed it - try it now, and let me know if it works.

Thanks,
Brett

> 
> Sincerely,
> Shannon
> 
> IBM e-business Integration Services
> 3200 Windy Hill Road - Atlanta, GA 30332 - WG06B
> Phone: 770-835-7672 T/L 445   FAX: 770-835-6479
> Internet: kendrick at us.ibm.com
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list