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

XML entity callback order differs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8, 11, 17, 22, 23
    • xml

      A DESCRIPTION OF THE PROBLEM :
      The issue described in JDK-6770436 also occurs for non-predefined entities.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use a DefaultHandler2, register lexical-handler, and parse this document:

      <!DOCTYPE x [<!ENTITY e "v">]><x>&e;</x>

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      startEntity: e
      characters: v
      endEntity: e
      ACTUAL -
      startEntity: e
      endEntity: e
      characters: v

      ---------- BEGIN SOURCE ----------
      import java.io.ByteArrayInputStream;
      import javax.xml.parsers.SAXParserFactory;
      import org.xml.sax.ext.DefaultHandler2;
      public class XmlEntityTest {
        public static void main(String[] args) throws Exception {
          var p = SAXParserFactory.newInstance().newSAXParser();
          var h = new DefaultHandler2() {
            public void startEntity(String name) {
              System.err.println("startEntity: " + name);
            }
            public void endEntity(String name) {
              System.err.println("endEntity: " + name);
            }
            public void characters(char[] ch, int start, int length) {
              System.err.println("characters: " + new String(ch, start, length));
            }
          };
          p.setProperty("http://xml.org/sax/properties/lexical-handler", h);
          String xml = "<!DOCTYPE x [<!ENTITY e \"v\">]><x>&e;</x>";
          p.parse(new ByteArrayInputStream(xml.getBytes()), h);
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always

            joehw Joe Wang
            pnarayanaswa Praveen Narayanaswamy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: