[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    Bug: XmlBeans does not support character encodings other than UTF-8
From:       Mark Swanson <mark () ScheduleWorld ! com>
Date:       2006-09-21 21:57:46
Message-ID: 45130ADA.9000006 () ScheduleWorld ! com
[Download RAW message or body]

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(XmlObjectBase.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: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic