elena       2002/08/15 10:51:22

  Modified:    java/src/org/apache/xerces/impl XMLDocumentScannerImpl.java
  Log:
  Bug fix: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9664.
  
  The problem is reproducable when load-external-dtd feature is false and document has
  a doctype (no internal DTD).
  In this case we *forget* to send endDTD() call for SAX users. SAX has fewer events --
  startDTD and endDTD -- where XNI also has doctypeDecl call. So in the pipeline we
  send doctypeDecl event and in SAX we convert it to startDTD(). That means that in SAX
  if we receive XNI startDTD call we ignore it. That also means that in the current 
code if we
  don't need to load external DTD we will never send XNI startDTD()/endDTD calls. This 
will
  cause problem in SAX since it already received startDTD() call (==doctypeDecl()) and 
it needs to receive endDTD() call.
  
  The patch forces XNI pipeline to send startDTD()/endDTD() calls in this case.
  
  Revision  Changes    Path
  1.21      +16 -4     
xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java
  
  Index: XMLDocumentScannerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- XMLDocumentScannerImpl.java       1 Aug 2002 17:12:09 -0000       1.20
  +++ XMLDocumentScannerImpl.java       15 Aug 2002 17:51:22 -0000      1.21
  @@ -708,19 +708,30 @@
                                   reportFatalError("AlreadySeenDoctype", null);
                               }
                               fSeenDoctypeDecl = true;
  +
  +                            // scanDoctypeDecl() sends XNI doctypeDecl event that 
  +                            // in SAX is converted to startDTD() event.
                               if (scanDoctypeDecl()) {
                                   setScannerState(SCANNER_STATE_DTD_INTERNAL_DECLS);
                                   setDispatcher(fDTDDispatcher);
                                   return true;
                               }
  -                            if (fDoctypeSystemId == null) {
  -                                fDTDScanner.setInputSource(null);
  -                            }
  +
                               if (fDoctypeSystemId != null && ((fValidation || 
fLoadExternalDTD) 
                                       && (fValidationManager == null || 
!fValidationManager.isCachedDTD()))) {
                                   setScannerState(SCANNER_STATE_DTD_EXTERNAL);
                                   setDispatcher(fDTDDispatcher);
                                   return true;
  +                            } 
  +                            else {
  +                                // Send endDTD() call if: 
  +                                // a) systemId is null
  +                                // b) "load-external-dtd" and validation are false
  +                                // c) DTD grammar is cached
  +                                
  +                                // in XNI this results in 3 events:  doctypeDecl, 
startDTD, endDTD
  +                                // in SAX this results in 2 events: startDTD, endDTD
  +                                fDTDScanner.setInputSource(null);
                               }
                               setScannerState(SCANNER_STATE_PROLOG);
                               break;
  @@ -793,6 +804,7 @@
                               // REVISIT: Should there be a feature for
                               //          the "complete" parameter?
                               boolean completeDTD = true;
  +
                               boolean moreToScan = 
fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && 
fLoadExternalDTD);
                               if (!moreToScan) {
                                   // end doctype declaration
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to