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
|