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

2 SAX features does not work properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 7, 8
    • xml
    • windows-i586, jdk8/b54

    • b63

        Attached test code are used to check skippedEntity() in org.xml.sax.ContentHandler interface.

        As description from http://docs.oracle.com/javase/7/docs/api, skippedEntity() callback will be triggered when below 2 SAX features are set as FALSE:
        http://xml.org/sax/features/external-general-entities
        http://xml.org/sax/features/external-parameter-entities

        But actually it does not work during external .dtd parsing, below is log:
        =====================
        startDocument() is invoked
        customVersion
        customEncoding
        startDTD() is invoked
        elementDecl() is invoked for element : toys
        elementDecl() is invoked for element : toy
        attributeDecl() is invoked for attr :id
        internalEntityDecl() is invoked for entity : name1
        internalEntityDecl() is invoked for entity : name2
        elementDecl() is invoked for element : name
        elementDecl() is invoked for element : price
        endDTD() is invoked

           Document : toys.xml
           Created on : August 21, 2012
           Author : Patrick Zhang
           Description: Sample test file for org.xml.sax.ext.DefaultHandler2

        startPrefixMapping() is invoked for ns1 : http://ns1.java.com
        startCDATA() is invoked
        endCDATA() is invoked

        toy id=1
              name : toy1's name price : 98470
        toy id=2
              name : toy2's name price : 345
        endPrefixMapping() is invoked for ns1

        endDocument() is invoked
        ===================

        There are several problems in above log:
        1. entities included in external dtd, here we mean "&name1;" and "&name2;", still can be recognized during paring. It does not work as expected. It should be ignored according to definition of the 2 features.
        2. Actually when we set below feature as FALSE, the entities are ignored really. But we do not see skippedEitity() are triggered:
        http://apache.org/xml/features/nonvalidating/load-external-dtd

          1. DefaultHandlerTest.java
            3 kB
          2. externalDTD2.dtd
            0.2 kB
          3. MyDefaultHandler2.java
            6 kB
          4. toys2.xml
            0.5 kB

              joehw Joe Wang
              pzhang Patrick Zhang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: