Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6560186

Stax XMLEvent.writeAsEncodedUnicode not outputting to writer

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: xml
    • Labels:

      Description

      FULL PRODUCT VERSION :
      1.6.0_01

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      javax.xml.stream.events.XMLEvent.writeAsEncodeUnicode does not appear to function . I haven't tested all events, but it certainly does not work for start/end element events or characters.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code supplied

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I was expecting the output to be the same as String str.
      ACTUAL -
      No output at all

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no message

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.io.CharArrayWriter;
      import java.io.StringReader;

      import javax.xml.stream.XMLEventReader;
      import javax.xml.stream.XMLInputFactory;
      import javax.xml.stream.XMLStreamException;
      import javax.xml.stream.events.XMLEvent;

      public class testStaxEventWriting {

      /**
      * @param args
      */
      public static void main(String[] args) {

      String str = "<html><p>some text</p>\n</html>";

      StringReader sr = new StringReader(str);

      XMLInputFactory inputFactory = XMLInputFactory.newInstance();

      XMLEventReader reader = null;
      try {
      reader = inputFactory.createXMLEventReader(sr);
      } catch (XMLStreamException e) {
      e.printStackTrace();
      return;
      }

      CharArrayWriter writer = new CharArrayWriter();
      while (reader.hasNext()){
      try {
      XMLEvent event = reader.nextEvent();
      event.writeAsEncodedUnicode(writer);
      } catch (XMLStreamException e) {
      e.printStackTrace();
      return;
      }
      }
      writer.close();
      System.out.println(writer.toString());
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I will extend the existing event classes with working output methods and create an event factory to serve them up.

        Attachments

          Activity

            People

            • Assignee:
              joehw Joe Wang
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: