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

sjsxp issue 32: NullPointerException in XMLDOMWriterImpl.writeCharacters()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 7
    • xml
    • b14
    • generic
    • generic
    • Verified

        If you try to write some characters outside of an element you get a null
        pointer exception. I'm trying to write a newline character into the DOM so
        that it prints nicely when serialized. Here's my code:

              _xmlStreamWriter.writeStartDocument();
              _xmlStreamWriter.writeCharacters("\n");

        Here's the error:
        java.lang.NullPointerException
        at com.sun.xml.stream.writers.XMLDOMWriterImpl.writeCharacters
        (XMLDOMWriterImpl.java:311)------- Additional comments from joehw Tue Mar 6 01:42:21 +0000 2007 -------

        The above code would result in an attempt to append a text node to the Document
        object. Refer to <a
        href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Embedded-DOM">DOM
        spec</a>, the action is not permitted.

        However, there is a bug in the impl class that causes it to throw a null pointer
        exception instead of the DOMExectpion: HIERARCHY_REQUEST_ERR: An attempt was
        made to insert a node where it is not permitted. This has been fixed. The above
        code would now throw HIERARCHY_REQUEST_ERR exception.

              joehw Joe Wang
              joehw Joe Wang
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: