[jdom-interest] ResultSetBuilder issue

Mark Hale Mark at beforethecall.com
Wed Nov 9 08:21:23 PST 2005


We use the following to pretty print our xml output. You are welcome to
try it to see if it works.

One bug we encoutered along the way. In BEA WebLogic, you will get a
single mystery binary character in the xml output if you do not use a
format (e.g. Format.getPrettyFormat()) as input to XMLOutputter.  The
character is only visible when viewing the output in hex format.

	Mark





////////////////  Java Code

   /**
     * A quicky function to print out a jdom Document.  Nicely formated.
     *
     * @param document      The jdom document you want to look at.
     *
     * @rerturn String of your nicely formated Document.
     */
    static public String  getString(Document document) {

        if (document==null) {
            return "";
        }


        XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
        ByteArrayOutputStream output = new ByteArrayOutputStream();

        try {
            fmt.output(document ,output);
        } catch (java.io.IOException ex) {
            return "";
        }

        return(output.toString());  //Dumps XML file
    }




    /**
     * A quicky function to return a jdom Element.  Nicely formated.
     *
     * @param element       The jdom element you want to look at.
     *
     * @rerturn String of your nicely formated Element.
     */
    public static String getString(Element element) {

        if (element==null) {
            return "";
        }

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        try {
            XMLOutputter fmt = new
XMLOutputter(Format.getPrettyFormat());
            fmt.output(element ,output);
        } catch (java.io.IOException ex) {
            return "";
        }
        return(output.toString());  //Dumps XML file
    }


////////////////  End Java Code

 

> -----Original Message-----
> From: jdom-interest-bounces at jdom.org 
> [mailto:jdom-interest-bounces at jdom.org] On Behalf Of WD
> Sent: Wednesday, November 09, 2005 7:21 AM
> To: jdom-interest at jdom.org
> Subject: RE: [jdom-interest] ResultSetBuilder issue
> 
> 
> When I use XMLOutputter, the outpout is as follows
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <result />
> 
> The problme is that it does not contain the data from 
> ResultSet. I have verified that the ResultSet is populated 
> with the data.
> 
> 
> 
> 
>  --- On Tue 11/08, Anderson, Paul D < 
> paul.d.anderson at boeing.com > wrote:
> From: Anderson, Paul D [mailto: paul.d.anderson at boeing.com]
> To: jdom-interest at jdom.org
> Date: Tue, 8 Nov 2005 14:53:46 -0800
> Subject: RE: [jdom-interest] ResultSetBuilder issue
> 
> <br>You are outputting the document directly and you need to 
> use an<br>outputter. See org.jdom.output.<br>Your output is 
> the correct output of the Document.toString() 
> method.<br><br>-----Original Message-----<br>From: WD 
> [mailto:webdevil2003 at excite.com] <br>Sent: Tuesday, November 
> 08, 2005 2:38 PM<br>To: jdom-interest at jdom.org<br>Subject: 
> [jdom-interest] ResultSetBuilder issue<br><br><br>Hi 
> All,<br>I have created a utility class that provides a method 
> to get the<br>Document out of ResultSet object and then I 
> created a JUnit test case to<br>test this utility class. I 
> execute JDBC statement and get the ResultSet,<br>but when I 
> try to get the Document out of this ResultSet, it is 
> not<br>working. I am getting the following as an out 
> put<br><br>[Document:  No DOCTYPE declaration, Root is 
> [Element: <result/>]]<br><br>I am using mysql. I have 
> verified that the ResultSet is populated with<br>the data. 
> What could be the 
> reason?<br><br>Thanks<br>WD<br><br><br><br><br>_______________
________________________________<br>Join Excite! - >
http://www.excite.com<br>The most personalized portal on the 
> Web!<br><br><br>______________________________________________
> _<br>To control your jdom-interest 
> membership:<br>http://www.jdom.org/mailman/options/jdom-intere
st/youraddr at yourhost.com<br><br>________________________________>
_______________<br>To control your jdom-interest 
> membership:<br>http://www.jdom.org/mailman/options/jdom-intere
st/youraddr at yourhost.com<br>
> 
> _______________________________________________
> Join Excite! - http://www.excite.com
> The most personalized portal on the Web!
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you
rhost.com
> 
> 




More information about the jdom-interest mailing list