JDK-8000172 : 2 SAX features does not work properly
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 7,8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-09-27
  • Updated: 2013-05-13
  • Resolved: 2012-10-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40Fixed 8 b63Fixed
Description
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


Comments
name1/name2 are entities defined in an external DTD, but are not external general entities, which is why they are resolved when the external dtd is loaded. external general entities are defined as: <!ENTITY name SYSTEM uri> or <!ENTITY name PUBLIC FPI uri> The bug in the reported case is that when external dtd is not loaded, skippedEntity event should be reported.
06-10-2012