From: "Mike Skells (ebizz-consulting)" <[EMAIL PROTECTED]> > Shouldn't we have some other entites in there as well > E.g. "
dom4j should already be handling the standard entities correctly I think. & " < > etc. > Also as a performance issue (and off topic) I noticed that the XMLWriter > seems very keen to flush the elements/attributes after each call. Is > there a reason for this. Would it be better to flush only once?? Yes; there have been some issues in the past with folks using an OutputStream which we need to wrap as an OutputStreamWriter along with a buffer for performance and sometimes folks want to call write() and assume that things get flushed automatically for them. Maybe we could make this a configurable option; so you could turn off autoflushing and just flush once at the end? James > > Mike Skells > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] On Behalf Of Dan Jacobs > Sent: Thursday 20 June 2002 04:11 > To: [EMAIL PROTECTED] > Subject: [dom4j-dev] fix for writing numeric entities in XMLWriter > > > I found and fixed a simple bug in XMLWriter.java. A fixed version is > attached, but not checked into the source repository. I'll leave that > for the folks who maintain the sources. > > If you parse and print out (using asXML) an XML document containing a > numeric entity reference such as   (the code for ) the code > was just writing out a byte with a value of 160 (decimal). The fix > (abstracted below) is to check for characters with integer codes below > 32 and above 126 (excluding standard whitespace characters) and encode > them as numeric entities. The same fix is made in two places in > XMLWriter.java. > > Thanks for reading. > -- Dan Jacobs > > char c; // declaration and assignment added by Dan > Jacobs > switch( c = text.charAt(i) ) { > case '<' : > entity = "<"; > break; > case '>' : > entity = ">"; > break; > case '&' : > entity = "&"; > break; > > //!!! Begin code added by Dan Jacobs !!!// > case '\t': case '\n': case '\r': > // don't encode standard whitespace characters > break; > default: > // encode low and high characters as entities > if ((c < 32) || (c >= 127)) > entity = "&#" + (int)c + ";"; > break; > //!!! End code added by Dan Jacobs !!!// > } > > -- > Daniel S. Jacobs > President, Model Objects Group > Object-Orient Software Engineering > Java & Web Application Development > > > > > _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com ------------------------------------------------------- Sponsored by: ThinkGeek at http://www.ThinkGeek.com/ _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev