Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-10

XmlTokenSource.save() does not use specified character encoding

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Won't Fix
    • Affects Version/s: unspecified
    • Fix Version/s: None
    • Component/s: Binding
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: PC

      Description

      Saving the in-memory XML via the .save(Writer w, XmlOptions options) method
      inherited from XmlTokenSource does not honour the specified character encoding.

      Example:

      {
      // ... code above

      // GENERATE THE RESPONSE OBJECT.
      XLSType responseXLS = processXLSDocument(requestXLS,
      globalRequestContext);

      // SERIALIZE THE RESPONSE OBJECT.
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      OutputStreamWriter osw = new OutputStreamWriter(bos, "ISO-8859-1");

      // Serialize the response.
      xlsDoc = XLSDocument.Factory.newInstance();
      xlsDoc.setXLS(responseXLS);

      opts = new XmlOptions();
      opts.setCharacterEncoding("ISO-8859-1");
      opts.setUseDefaultNamespace();
      opts.setSaveAggresiveNamespaces();

      xlsDoc.save(osw, opts);
      osw.flush();
      osw.close();

      // ... code below

      Always produces a document that is encoded in UTF-8 (xml header <?xml
      version="1.0" encoding="UTF-8"?>).

      Incidentally, I haven't been able to find the list of character encodings that
      is supported by XMLBeans.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              michael.gris@autodesk.com Michael Gris
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: