Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-1859

XMLSerializer does not produce XML 1.1 header

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3
    • 2.3
    • Core Java Framework
    • None

    Description

      If you create an XMLSerializer and set its output stream, and then call sax2xml.setOutputProperty(OutputKeys.VERSION, "1.1"), the output XML file will have an <?xml version="1.0"...> header instead of the desired version="1.1".

      A workaround is to call sax2xml.setOutputProperty(OutputKeys.VERSION, "1.1") before setting the output stream.

      Test case:
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLSerializer sax2xml = new XMLSerializer(baos, false);
      sax2xml.setOutputProperty(OutputKeys.VERSION, "1.1");
      ContentHandler ch = sax2xml.getContentHandler();
      ch.startDocument();
      ch.startElement("","foo","foo", new AttributesImpl());
      ch.endElement("", "foo", "foo");
      ch.endDocument();
      String xmlStr = new String(baos.toByteArray(), "UTF-8");
      assertEquals("<?xml version=\"1.1\" encoding=\"UTF-8\"?><foo/>", xmlStr);

      Attachments

        Activity

          People

            schor Marshall Schor
            alally Adam P. Lally
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: