You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by zo...@ca.ibm.com on 2001/03/21 00:03:34 UTC

Patch for [Bug 845] - external subset and INCLUDE sections

Hello,

     I was taking a look at defect 845 in Bugzilla (
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=845).  The example
(well-formed) document throws an exception when run through sax.SAXCount.

---BEGIN excerpt from 845---

   *** test.xml ***

    <?xml version="1.0"?>
    <!DOCTYPE book [
    <!ENTITY % TEST SYSTEM "test.ent">
    %TEST;
    ]>
    <book/>

   *** test.ent ***

    <![INCLUDE[
    <!ELEMENT book EMPTY>
    ]]>

   I did:

     java sax.SAXCount test.xml

   [Fatal Error] test.ent:3:2: The document type declaration for root
   element type "book" must end with '>'.

---END excerpt from 845---


     It looks like what is happening is that the loop in
XMLDTDScanner.scanDecls(boolean) assumes that if it encounters a right
bracket, and it's not processing the ExternalID of the doctypedecl
production, then it must have reached the closing right bracket that
appears at the end of the (poorly named) internal subset.  However, in the
example what it has really encountered is the first right bracket ending
the INCLUDE in test.ent.

     IGNORE doesn't have the same problem, because processing for it is
completely self-contained:  it consumes characters, making sure all
brackets, etc. are balanced.

     So, I made the following change to
xml-xerces/java/src/org/apache/xerces/framework/XMLDTDScanner.java, which
appears to fix the problem.

diff -r1.17 XMLDTDScanner.java
1400c1400,1401
<             if (!extSubset && fEntityReader.lookingAtChar(']', false)) {
---
>             if (fEntityReader.lookingAtChar(']', false) &&
>                 !getReadingExternalEntity()) {


(See attached file: XMLDTDScanner.diff)

Thanks,

Henry
------------------------------------------------------------------------
Henry Zongaro      XML Parsers development
IBM SWS Toronto Lab   Tie Line 778-6044;  Phone (416) 448-6044
mailto:zongaro@ca.ibm.com