Try to construct an InputStreamReader obj from your InputStream obj: InputStreamReader reader = new InputStreamReader(is, encoding);
And construct an OutputStreamWriter from your ByteArrayOutputStream: OutputStreamWriter writer = new OutputStreamWriter(baos, encoding); Then do you reading, writing stuff If you end up creating a new XmlObject for the desired encoding, try to set the encoding property on the new XmlObject: targetDoc.documentProperties().setEncoding(encoding); Hope that helps. -----Original Message----- From: Mark Swanson [mailto:[EMAIL PROTECTED] Sent: Thursday, September 21, 2006 3:58 PM To: [email protected] Subject: Bug: XmlBeans does not support character encodings other than UTF-8 Hello, I'm trying to get XmlBeans to persist using a specific character set: UNICODEBIG. XmlDocumentProperties xmlDocumentProperties = doc.documentProperties(); String encoding = xmlDocumentProperties.getEncoding(); Logger.info("response encoding:" + encoding); (encoding is UNICODEBIG) XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setSavePrettyPrint(); xmlOptions.setSavePrettyPrintIndent(4); xmlOptions.setSaveOuter(); ByteArrayOutputStream baos = new ByteArrayOutputStream(2048); InputStream is = doc.newInputStream(xmlOptions); byte[] buffer = new byte[2048]; int length = 0; while (true) { length = is.read(buffer, 0, 2048); if (length < 0) break; baos.write(buffer, 0, length); } I need to state the prologue, and XmlBeans is printing a prologue with the wrong character set: UTF-8. <?xml version="1.0" encoding="UTF-8"?> ... The document has the UNICODEBIG encoding. Yet, it prints out as UTF-8. This is contrary to the javadocs which says newInputStream() takes the encoding into account. I tried xmlOptions.setCharacterEncoding() but that fails with: java.lang.RuntimeException: java.io.UnsupportedEncodingException: UNICODEBIG at org.apache.xmlbeans.impl.store.Saver$InputStreamSaver.<init>(Saver.java: 1785) at org.apache.xmlbeans.impl.store.Cursor._newInputStream(Cursor.java:552) at org.apache.xmlbeans.impl.store.Cursor.newInputStream(Cursor.java:2442) at org.apache.xmlbeans.impl.values.XmlObjectBase.newInputStream(XmlObjectBa se.java:156) I'm using XmlBeans 2.1.0. Does anyone have any ideas as to why the Document's encoding properties are being ignored? Thank you. -- Free replacement for Exchange and Outlook (Contacts and Calendar) http://www.ScheduleWorld.com/tg/ WebDAV: http://www.ScheduleWorld.com/sw/webDAVDir/4000.ics VFREEBUSY: http://www.ScheduleWorld.com/sw/freebusy/4000.ifb --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] >>Register now for BEA World 2006 --- See http://www.bea.com/beaworld<< _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
