You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2001/01/10 08:45:47 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/validation/grammars DTDGrammar.java SchemaGrammar.java

andyc       01/01/09 23:45:47

  Modified:    java/src/org/apache/xerces/impl/validation Tag: xerces_j_2
                        Grammar.java GrammarPool.java
               java/src/org/apache/xerces/impl/validation/datatypes Tag:
                        xerces_j_2 DatatypeMessageProvider.java
               java/src/org/apache/xerces/impl/validation/grammars Tag:
                        xerces_j_2 DTDGrammar.java SchemaGrammar.java
  Log:
  Some basic updates to grammar objects to prepare for
  new features/re-working of validation code.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.29  +11 -3     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.28
  retrieving revision 1.1.2.29
  diff -u -r1.1.2.28 -r1.1.2.29
  --- Grammar.java	2001/01/04 08:17:01	1.1.2.28
  +++ Grammar.java	2001/01/10 07:45:45	1.1.2.29
  @@ -92,14 +92,19 @@
    * @author Eric Ye, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: Grammar.java,v 1.1.2.28 2001/01/04 08:17:01 andyc Exp $
  + * @version $Id: Grammar.java,v 1.1.2.29 2001/01/10 07:45:45 andyc Exp $
    */
  -public class Grammar {
  +public abstract class Grammar {
   
       //
       // Constants
       //
   
  +    /** Top level scope (-1). */
  +    public static final int TOP_LEVEL_SCOPE = -1;
  +
  +    // private
  +
       /** Chunk shift (8). */
       private static final int CHUNK_SHIFT = 8; // 2^8 = 256
   
  @@ -249,12 +254,15 @@
       //
   
       /** Default constructor. */
  -    public Grammar() {
  +    protected Grammar() {
       } // <init>()
   
       //
       // Public methods
       //
  +
  +    /** Returns true if this grammar is namespace aware. */
  +    public abstract boolean isNamespaceAware();
   
       /** Returns this grammar's target namespace. */
       public String getTargetNamespace() {
  
  
  
  1.1.2.5   +70 -21    xml-xerces/java/src/org/apache/xerces/impl/validation/Attic/GrammarPool.java
  
  Index: GrammarPool.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/Attic/GrammarPool.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- GrammarPool.java	2001/01/05 09:33:27	1.1.2.4
  +++ GrammarPool.java	2001/01/10 07:45:45	1.1.2.5
  @@ -60,13 +60,15 @@
   import java.util.Hashtable;
   
   /**
  - * A grammar pool.
  + * Stores grammars in a pool associated to a specific key. This grammar pool
  + * implementation stores two types of grammars: those keyed by the root element
  + * name, and those keyed by the grammar's target namespace.
    *
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
    * @author Jeffrey Rodriguez, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: GrammarPool.java,v 1.1.2.4 2001/01/05 09:33:27 andyc Exp $
  + * @version $Id: GrammarPool.java,v 1.1.2.5 2001/01/10 07:45:45 andyc Exp $
    */
   public class GrammarPool {
   
  @@ -74,9 +76,12 @@
       // Data
       //
   
  -    /** Grammars. */
  +    /** Grammars associated with element root name. */
       protected Hashtable fGrammars = new Hashtable();
   
  +    /** Grammars associated with namespaces. */
  +    protected Hashtable fGrammarsNS = new Hashtable();
  +
       //
       // Constructors
       //
  @@ -90,45 +95,89 @@
       //
   
       /**
  -     * Puts the specified grammar into the grammar pool.
  +     * Puts the specified grammar into the grammar pool and associate it to
  +     * a root element name.
        * 
  -     * @param key Key to associate with grammar.
  -     * @param grammar Grammar object.
  +     * @param rootElement Root element name.
  +     * @param grammar     The grammar.
        */
  -    public void putGrammar(String key, Grammar grammar) {
  -        fGrammars.put(key, grammar);
  +    public void putGrammar(String rootElement, Grammar grammar) {
  +        fGrammars.put(rootElement, grammar);
       } // putGrammar(String,Grammar)
   
  +    /**
  +     * Puts the specified grammar into the grammar pool and associate it to
  +     * a target namespace.
  +     *
  +     * @param namespace The grammar namespace.
  +     * @param grammar   The grammar.
  +     */
  +    public void putGrammarNS(String namespace, Grammar grammar) {
  +        fGrammarsNS.put(namespace, grammar);
  +    } // putGrammarNS(String,Grammar)
  +
       /**
  -     * Returns the grammar associated to the specified key.
  +     * Returns the grammar associated to the specified root element name.
        * 
  -     * @param key The key of the grammar.
  +     * @param rootElement Root element name.
        */
  -    public Grammar getGrammar(String key) {
  -        return (Grammar)fGrammars.get(key);
  +    public Grammar getGrammar(String rootElement) {
  +        return (Grammar)fGrammars.get(rootElement);
       } // getGrammar(String):Grammar
   
       /**
  -     * Removes the grammar associated to the specified key from the
  +     * Returns the grammar associated to the specified target namespace.
  +     * 
  +     * @param namespace Target namespace.
  +     */
  +    public Grammar getGrammarNS(String namespace) {
  +        return (Grammar)fGrammarsNS.get(namespace);
  +    } // getGrammarNS(String):Grammar
  +
  +    /**
  +     * Removes the grammar associated to the specified root elememt name from the
        * grammar pool and returns the removed grammar.
        * 
  -     * @param key The key of the grammar.
  +     * @param rootElement Root element name.
        */
  -    public Grammar removeGrammar(String key) {
  -        if (fGrammars.contains(key)) {
  -            return (Grammar)fGrammars.remove(key);
  +    public Grammar removeGrammar(String rootElement) {
  +        if (fGrammars.contains(rootElement)) {
  +            return (Grammar)fGrammars.remove(rootElement);
           }
           return null;
       } // removeGrammar(String):Grammar
   
       /**
  +     * Removes the grammar associated to the specified namespace from the
  +     * grammar pool and returns the removed grammar.
  +     * 
  +     * @param namespace Target namespace.
  +     */
  +    public Grammar removeGrammarNS(String namespace) {
  +        if (fGrammarsNS.contains(namespace)) {
  +            return (Grammar)fGrammarsNS.remove(namespace);
  +        }
  +        return null;
  +    } // removeGrammarNS(String):Grammar
  +
  +    /**
        * Returns true if the grammar pool contains a grammar associated
  -     * to the specified key.
  +     * to the specified root element name.
        *
  -     * @param key The key of the grammar.
  +     * @param rootElement Root element name.
        */
  -    public boolean containsGrammar(String key) {
  -        return fGrammars.containsKey(key);
  +    public boolean containsGrammar(String rootElement) {
  +        return fGrammars.containsKey(rootElement);
       } // containsGrammar(String):boolean
  +
  +    /**
  +     * Returns true if the grammar pool contains a grammar associated
  +     * to the specified target namespace.
  +     *
  +     * @param namespace Target namespace.
  +     */
  +    public boolean containsGrammarNS(String namespace) {
  +        return fGrammarsNS.containsKey(namespace);
  +    } // containsGrammarNS(String):boolean
   
   } // class GrammarPool
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +2 -2      xml-xerces/java/src/org/apache/xerces/impl/validation/datatypes/Attic/DatatypeMessageProvider.java
  
  Index: DatatypeMessageProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/datatypes/Attic/DatatypeMessageProvider.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DatatypeMessageProvider.java	2000/10/13 02:43:10	1.1.2.1
  +++ DatatypeMessageProvider.java	2001/01/10 07:45:46	1.1.2.2
  @@ -67,7 +67,7 @@
   /**
    * 
    * @author Jeffrey Rodriguez
  - * @version $Id: DatatypeMessageProvider.java,v 1.1.2.1 2000/10/13 02:43:10 jeffreyr Exp $
  + * @version $Id: DatatypeMessageProvider.java,v 1.1.2.2 2001/01/10 07:45:46 andyc Exp $
    */
   public class DatatypeMessageProvider implements MessageFormatter {
       /**
  @@ -95,7 +95,7 @@
       public String formatMessage(Locale locale, String key, Object[] arguments)
          throws MissingResourceException{
          //TODO
  -       return "TODO";
  +       return "TODO: "+key;
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.36  +15 -6     xml-xerces/java/src/org/apache/xerces/impl/validation/grammars/Attic/DTDGrammar.java
  
  Index: DTDGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/grammars/Attic/DTDGrammar.java,v
  retrieving revision 1.1.2.35
  retrieving revision 1.1.2.36
  diff -u -r1.1.2.35 -r1.1.2.36
  --- DTDGrammar.java	2001/01/04 08:17:04	1.1.2.35
  +++ DTDGrammar.java	2001/01/10 07:45:46	1.1.2.36
  @@ -90,7 +90,7 @@
    * @author Jeffrey Rodriguez, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: DTDGrammar.java,v 1.1.2.35 2001/01/04 08:17:04 andyc Exp $
  + * @version $Id: DTDGrammar.java,v 1.1.2.36 2001/01/10 07:45:46 andyc Exp $
    */
   public class DTDGrammar
       extends Grammar
  @@ -493,8 +493,8 @@
           }
           fSimpleType.defaultValue      = defaultValue.length >= 0 ?  defaultValue.toString() : null;
           fSimpleType.enumeration       = enumeration;
  -        fSimpleType.datatypeValidator = fDatatypeValidatorFactory.createDatatypeValidator(type, null, null, false);
   
  +        Hashtable facets = new Hashtable();
           if (type.equals("CDATA")) {
               fSimpleType.type = XMLSimpleType.TYPE_CDATA;
           }
  @@ -523,20 +523,24 @@
           }
           else if (type.startsWith("NOTATION") ) {
               fSimpleType.type = XMLSimpleType.TYPE_NOTATION;
  -            Hashtable facets = new Hashtable();
               facets.put(SchemaSymbols.ELT_ENUMERATION, fSimpleType.enumeration);
           }
           else if (type.startsWith("ENUMERATION") ) {
               fSimpleType.type = XMLSimpleType.TYPE_ENUMERATION;
  -            Hashtable facets = new Hashtable();
               facets.put(SchemaSymbols.ELT_ENUMERATION, fSimpleType.enumeration);
           }
  +        else {
  +            // REVISIT: Report error message. -Ac
  +            System.err.println("!!! unknown attribute type "+type);
  +        }
  +        // REVISIT: The datatype should be stored with the attribute value
  +        //          and not special-cased in the XMLValidator. -Ac
  +        //fSimpleType.datatypeValidator = fDatatypeValidatorFactory.createDatatypeValidator(type, null, facets, fSimpleType.list);
   
           fQName.setValues(null, attributeName, attributeName, null);
           fAttributeDecl.setValues( fQName, fSimpleType, false );
   
  -        setAttributeDecl( elementIndex, fCurrentAttributeIndex,
  -                           fAttributeDecl );
  +        setAttributeDecl(elementIndex, fCurrentAttributeIndex, fAttributeDecl);
   
           int chunk = fCurrentAttributeIndex >> CHUNK_SHIFT;
           int index = fCurrentAttributeIndex & CHUNK_MASK;
  @@ -922,6 +926,11 @@
       //
       // Grammar methods
       //
  +
  +    /** Returns true if this grammar is namespace aware. */
  +    public boolean isNamespaceAware() {
  +        return false;
  +    } // isNamespaceAware():boolean
   
       /** Returns the element decl index. */
       public int getElementDeclIndex(QName elementDeclQName, int scope) {
  
  
  
  1.1.2.5   +10 -1     xml-xerces/java/src/org/apache/xerces/impl/validation/grammars/Attic/SchemaGrammar.java
  
  Index: SchemaGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/grammars/Attic/SchemaGrammar.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- SchemaGrammar.java	2000/11/03 22:59:54	1.1.2.4
  +++ SchemaGrammar.java	2001/01/10 07:45:46	1.1.2.5
  @@ -81,7 +81,7 @@
    *
    * @author ericye, IBM
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
  - * @version $Id: SchemaGrammar.java,v 1.1.2.4 2000/11/03 22:59:54 ericye Exp $
  + * @version $Id: SchemaGrammar.java,v 1.1.2.5 2001/01/10 07:45:46 andyc Exp $
    *
    */
   public class SchemaGrammar
  @@ -304,6 +304,15 @@
       public boolean isDTD() {
           return false;
       }
  +
  +    //
  +    // Grammar methods
  +    //
  +
  +    /** Returns true if this grammar is namespace aware. */
  +    public boolean isNamespaceAware() {
  +        return true;
  +    } // isNamespaceAware():boolean
   
       //
       // Protected methods