You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/11/30 02:28:03 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLDocumentScanner.java XMLDTDScanner.java XMLScanner.java

ericye      00/11/29 17:28:02

  Modified:    java/src/org/apache/xerces/impl Tag: xerces_j_2
                        XMLDocumentScanner.java XMLDTDScanner.java
                        XMLScanner.java
  Log:
  checking WFC and VC : Entity declared correctly, now XMLDTDScanner is 100% compliant,
  XMLDocumentScanner still needs information regarding whether a external  parameter entity
  was seen or not.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.76  +6 -6      xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java
  
  Index: XMLDocumentScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java,v
  retrieving revision 1.1.2.75
  retrieving revision 1.1.2.76
  diff -u -r1.1.2.75 -r1.1.2.76
  --- XMLDocumentScanner.java	2000/11/22 00:34:26	1.1.2.75
  +++ XMLDocumentScanner.java	2000/11/30 01:27:55	1.1.2.76
  @@ -105,8 +105,9 @@
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
    * @author Andy Clark, IBM
    * @author Arnaud  Le Hors, IBM
  + * @author Eric Ye, IBM
    *
  - * @version $Id: XMLDocumentScanner.java,v 1.1.2.75 2000/11/22 00:34:26 ericye Exp $
  + * @version $Id: XMLDocumentScanner.java,v 1.1.2.76 2000/11/30 01:27:55 ericye Exp $
    */
   public class XMLDocumentScanner
       extends XMLScanner
  @@ -237,9 +238,6 @@
       /** Namespaces. */
       protected boolean fNamespaces;
   
  -    /** Validation */
  -    protected boolean fValidation;
  -
       // dispatchers
   
       /** Active dispatcher. */
  @@ -341,7 +339,6 @@
           // sax features
           final String NAMESPACES = Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
           fNamespaces = componentManager.getFeature(NAMESPACES);
  -        fValidation = componentManager.getFeature(Constants.SAX_FEATURE_PREFIX+Constants.VALIDATION_FEATURE);
           fAttributes.setNamespaces(fNamespaces);
   
           // xerces properties
  @@ -542,6 +539,7 @@
           // set standalone
           fStandalone = standalone != null && standalone.equals("yes");
           fEntityManager.setStandalone(fStandalone);
  +        if (fDTDScanner != null) fDTDScanner.setStandalone(fStandalone);
   
           // call handler
           if (fDocumentHandler != null) {
  @@ -824,8 +822,10 @@
                   cdata = false;
               }
           }
  +        //REVISIT: one more case needs to be included: external PE and standalone is no
  +        boolean isVC =  fHasExternalDTD && !fStandalone;        
           scanAttributeValue(fString, fAttributeQName.rawname, attributes,
  -                           attributes.getLength() - 1, cdata, true);
  +                           attributes.getLength() - 1, cdata, isVC);
           attributes.setValue(attributes.getLength() - 1, fString.toString());
   
           if (DEBUG_CONTENT_SCANNING) System.out.println("<<< scanAttribute()");
  
  
  
  1.1.2.75  +32 -10    xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDTDScanner.java
  
  Index: XMLDTDScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDTDScanner.java,v
  retrieving revision 1.1.2.74
  retrieving revision 1.1.2.75
  diff -u -r1.1.2.74 -r1.1.2.75
  --- XMLDTDScanner.java	2000/11/21 23:14:25	1.1.2.74
  +++ XMLDTDScanner.java	2000/11/30 01:27:56	1.1.2.75
  @@ -88,8 +88,9 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    * @author Glenn Marcy, IBM
  + * @author Eric Ye, IBM
    *
  - * @version $Id: XMLDTDScanner.java,v 1.1.2.74 2000/11/21 23:14:25 ericye Exp $
  + * @version $Id: XMLDTDScanner.java,v 1.1.2.75 2000/11/30 01:27:56 ericye Exp $
    */
   public class XMLDTDScanner
       extends XMLScanner
  @@ -127,13 +128,7 @@
       // Data
       //
   
  -    // features
   
  -    /** 
  -     * Validation. This feature identifier is:
  -     * http://xml.org/sax/features/validation
  -     */
  -    protected boolean fValidation;
   
       /** fErrorReporter */
       protected XMLErrorReporter fErrorReporter;
  @@ -150,6 +145,15 @@
       /** Scanner state. */
       protected int fScannerState;
   
  +    /** fStandalone **/
  +    protected boolean fStandalone;
  +
  +    /** fSeenExternalDTD **/
  +    protected boolean fSeenExternalDTD;
  +
  +    /** fSeenExternalPE **/
  +    protected boolean fSeenExternalPE;
  +
       // private data
   
       private boolean fStartDTDCalled;
  @@ -186,6 +190,15 @@
       //
       // Methods
       //
  +    
  +    /**
  +     * Sets whether the document entity is standalone.
  +     *
  +     * @param standalone True if document entity is standalone.
  +     */
  +    public void setStandalone(boolean standalone) {
  +        fStandalone = standalone;
  +    } // setStandalone(boolean)
   
       /**
        * Scan an external DTD.
  @@ -205,6 +218,8 @@
           // set starting state
           setScannerState(SCANNER_STATE_TEXT_DECL);
   
  +        fSeenExternalDTD = true;
  +
           scanTextDecl(complete);
   
           if (fScannerState == SCANNER_STATE_END_OF_INPUT) {
  @@ -313,8 +328,6 @@
   
           super.reset(componentManager);
   
  -        // sax features
  -        fValidation = componentManager.getFeature(VALIDATION);
   
           // Xerces properties
           fGrammarPool = (GrammarPool)
  @@ -331,6 +344,10 @@
           fMarkUpDepth = 0;
           fPEDepth = 0;
   
  +        fStandalone = false;
  +        fSeenExternalDTD = false;
  +        fSeenExternalPE = false;
  +
       } // reset
   
       /**
  @@ -1202,9 +1219,10 @@
                   }
               }
               // AttValue 
  +            boolean isVC = !fStandalone  &&  (fSeenExternalDTD || fSeenExternalPE) ;
               scanAttributeValue(defaultVal, atName,
                                  fAttributes, 0, type.equals("CDATA"),
  -                               scanningInternalSubset());
  +                               isVC);
           }
           return defaultType;
   
  @@ -1309,6 +1327,10 @@
           scanExternalID(fStrings, false);
           String systemId = fStrings[0];
           String publicId = fStrings[1];
  +
  +        if (isPEDecl && systemId != null) {
  +            fSeenExternalPE = true;
  +        }
   
           String notation = null;
           // NDATA
  
  
  
  1.1.2.41  +29 -7     xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java
  
  Index: XMLScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java,v
  retrieving revision 1.1.2.40
  retrieving revision 1.1.2.41
  diff -u -r1.1.2.40 -r1.1.2.41
  --- XMLScanner.java	2000/11/20 02:01:42	1.1.2.40
  +++ XMLScanner.java	2000/11/30 01:28:00	1.1.2.41
  @@ -92,8 +92,9 @@
    *
    * @author Andy Clark, IBM
    * @author Arnaud  Le Hors, IBM
  + * @author Eric Ye, IBM
    *
  - * @version $Id: XMLScanner.java,v 1.1.2.40 2000/11/20 02:01:42 lehors Exp $
  + * @version $Id: XMLScanner.java,v 1.1.2.41 2000/11/30 01:28:00 ericye Exp $
    */
   public abstract class XMLScanner 
       implements XMLComponent {
  @@ -102,6 +103,14 @@
       // Data
       //
   
  +    // features
  +
  +    /** 
  +     * Validation. This feature identifier is:
  +     * http://xml.org/sax/features/validation
  +     */
  +    protected boolean fValidation;
  +    
       // properties
   
       /** Symbol table. */
  @@ -217,6 +226,9 @@
           fGtSymbol = fSymbolTable.addSymbol("gt");
           fQuotSymbol = fSymbolTable.addSymbol("quot");
           fAposSymbol = fSymbolTable.addSymbol("apos");
  +        
  +        // sax features
  +        fValidation = componentManager.getFeature(Constants.SAX_FEATURE_PREFIX+Constants.VALIDATION_FEATURE);
   
       } // reset(XMLComponentManager)
   
  @@ -612,8 +624,8 @@
        * @param attrIndex The index of the attribute to use from the list.
        * @param cdata Specifies whether the attribute is of type CDATA or not, so
        *              that the appropriate normalization can be performed.
  -     * @param checkEntities Specifies whether undeclared entities should be
  -     *                      checked.
  +     * @param checkEntities true if undeclared entities should be reported as VC violation,  
  +     *                      false if undeclared entities should be reported as WFC violation.
        *
        * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
        * at the time of calling is lost.
  @@ -835,10 +847,20 @@
                                                    new Object[] { entityName });
                               }
                               else {
  -                                if (checkEntities &&
  -                                    !fEntityManager.isDeclaredEntity(entityName)) {
  -                                    reportFatalError("EntityNotDeclared",
  -                                                     new Object[]{entityName});
  +                                if (!fEntityManager.isDeclaredEntity(entityName)) {
  +                                    //WFC & VC: Entity Declared
  +                                    if (checkEntities) {
  +                                        if (fValidation) {
  +                                            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                                                                       "EntityNotDeclared",
  +                                                                       new Object[]{entityName},
  +                                                                       XMLErrorReporter.SEVERITY_ERROR);
  +                                        }
  +                                    }
  +                                    else {
  +                                        reportFatalError("EntityNotDeclared",
  +                                                         new Object[]{entityName});
  +                                    }
                                   }
                                   fEntityManager.startEntity(entityName, true);
                               }