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

XmlTokenSource.save() does not use specified character encoding

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Won't Fix
    • unspecified
    • None
    • Binding
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: