You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@apache.org on 2001/02/13 19:36:18 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/validation Grammar.java

lehors      01/02/13 10:36:17

  Modified:    java/src/org/apache/xerces/impl Tag: xerces_j_2
                        XMLDocumentScanner.java
               java/src/org/apache/xerces/impl/validation Tag: xerces_j_2
                        Grammar.java
  Log:
  decouple a little the XMLDocumentScanner from the Grammar by using
  a new method called isCDATAAttribute on Grammar.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.79  +4 -16     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.78
  retrieving revision 1.1.2.79
  diff -u -r1.1.2.78 -r1.1.2.79
  --- XMLDocumentScanner.java	2000/12/27 10:15:11	1.1.2.78
  +++ XMLDocumentScanner.java	2001/02/13 18:36:11	1.1.2.79
  @@ -67,8 +67,6 @@
   import org.apache.xerces.impl.msg.XMLMessageFormatter;
   import org.apache.xerces.impl.validation.Grammar;
   import org.apache.xerces.impl.validation.GrammarPool;
  -import org.apache.xerces.impl.validation.XMLAttributeDecl;
  -import org.apache.xerces.impl.validation.XMLSimpleType;
   
   import org.apache.xerces.util.XMLAttributesImpl;
   import org.apache.xerces.util.XMLStringBuffer;
  @@ -107,7 +105,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Eric Ye, IBM
    *
  - * @version $Id: XMLDocumentScanner.java,v 1.1.2.78 2000/12/27 10:15:11 andyc Exp $
  + * @version $Id: XMLDocumentScanner.java,v 1.1.2.79 2001/02/13 18:36:11 lehors Exp $
    */
   public class XMLDocumentScanner
       extends XMLScanner
  @@ -230,9 +228,6 @@
       /** Element stack. */
       protected ElementStack fElementStack = new ElementStack();
   
  -    /** Attribute decl. */
  -    protected XMLAttributeDecl fAttributeDecl = new XMLAttributeDecl();
  -
       // features
   
       /** Namespaces. */
  @@ -825,21 +820,14 @@
           }
   
           // get the attribute type from the Grammar
  -        if (fCurrentGrammar == null) {
  +        if (fCurrentGrammar == null && fGrammarPool != null) {
               // REVISIT: should we use the systemId as the key instead?
               fCurrentGrammar = fGrammarPool.getGrammar("");
           }
           boolean cdata = true;
           if (fCurrentGrammar != null) {
  -            int elDeclIdx =
  -                fCurrentGrammar.getElementDeclIndex(fCurrentElement, -1);
  -            int atDeclIdx =
  -                fCurrentGrammar.getAttributeDeclIndex(elDeclIdx,
  -                                                      fAttributeQName.rawname);
  -            if (fCurrentGrammar.getAttributeDecl(elDeclIdx, fAttributeDecl)
  -                && fAttributeDecl.simpleType.type != XMLSimpleType.TYPE_CDATA){
  -                cdata = false;
  -            }
  +            cdata = fCurrentGrammar.isCDATAAttribute(fCurrentElement,
  +                                                     fAttributeQName);
           }
           //REVISIT: one more case needs to be included: external PE and standalone is no
           boolean isVC =  fHasExternalDTD && !fStandalone;        
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.32  +24 -1     xml-xerces/java/src/org/apache/xerces/impl/validation/Attic/Grammar.java
  
  Index: Grammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/Attic/Grammar.java,v
  retrieving revision 1.1.2.31
  retrieving revision 1.1.2.32
  diff -u -r1.1.2.31 -r1.1.2.32
  --- Grammar.java	2001/01/30 04:17:02	1.1.2.31
  +++ Grammar.java	2001/02/13 18:36:15	1.1.2.32
  @@ -95,7 +95,7 @@
    * @author Eric Ye, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: Grammar.java,v 1.1.2.31 2001/01/30 04:17:02 andyc Exp $
  + * @version $Id: Grammar.java,v 1.1.2.32 2001/02/13 18:36:15 lehors Exp $
    */
   public abstract class Grammar {
   
  @@ -250,6 +250,9 @@
       /** Temporary qualified name. */
       private QName fQName2 = new QName();
   
  +    /** Temporary Attribute decl. */
  +    protected XMLAttributeDecl fAttributeDecl = new XMLAttributeDecl();
  +
       // for buildSyntaxTree method
   
       private int fLeafCount = 0;
  @@ -454,6 +457,26 @@
           return true;
   
       } // getAttributeDecl
  +
  +
  +    /**
  +     * Returns whether the given attribute is of type CDATA or not
  +     *
  +     * @param elName The element name.
  +     * @param atName The attribute name.
  +     *
  +     * @return true if the attribute is of type CDATA
  +     */
  +    public boolean isCDATAAttribute(QName elName, QName atName) {
  +        int elDeclIdx = getElementDeclIndex(elName, -1);
  +        int atDeclIdx = getAttributeDeclIndex(elDeclIdx, atName.rawname);
  +        if (getAttributeDecl(elDeclIdx, fAttributeDecl)
  +            && fAttributeDecl.simpleType.type != XMLSimpleType.TYPE_CDATA){
  +            return false;
  +        }
  +        return true;
  +    }
  +
   
       /**
        * getFirstEntityDeclIndex