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

Jaxp Issue 58: XML processing instruction parsing error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 7
    • xml
    • 6
    • h1146
    • generic
    • generic
    • Verified

        A piece of code that we have that used to work in Java 1.5/JAXP 1.3 is broken
        in Java 1.6/JAXP 1.4. Here is a boiled-down version of the java code that
        demonstrates the problem. The output from the java file should be "foo", but
        comes out as "". The XML in question starts with a processing instruction and
        no prolog, but I think the parser gets confused and treats it as the prolog but
        throws away the data.. not really sure.

        import java.io.*;
        import org.w3c.dom.*;
        import org.xml.sax.*;
        import com.sun.org.apache.xerces.internal.parsers.*;

        class test {
          public static void main( String[] args ) throws Exception {
            ByteArrayInputStream bais = new ByteArrayInputStream( "<?xmltarget foo?
        ><test></test>".getBytes() );
            DOMParser p = new DOMParser();
            p.parse( new InputSource( bais ) );
            System.out.println( ( (ProcessingInstruction)p.getDocument().getFirstChild
        () ).getData() );
          }
        }

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

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: