You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2002/02/09 21:55:21 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/xni/grammars XMLGrammarDescription.java Grammar.java

neilg       02/02/09 12:55:21

  Modified:    java/src/org/apache/xerces/impl/xs XSDDescription.java
                        SchemaGrammar.java
               java/src/org/apache/xerces/impl/xs/traversers
                        XSDHandler.java
               java/src/org/apache/xerces/impl/dtd XMLDTDDescription.java
                        AbstractDTDGrammar.java
               java/src/org/apache/xerces/parsers
                        XMLGrammarCachingConfiguration.java
               java/src/org/apache/xerces/xni/grammars
                        XMLGrammarDescription.java Grammar.java
  Log:
  updating Grammar and XMLGrammarDescription interfaces consistent with recent discussions on the xerces-j-dev list.  Now Grammars have XMLGrammarDescription objects, and the getGrammarType method is only found in the XMLGrammarDescription interface.
  
  Revision  Changes    Path
  1.2       +5 -24     xml-xerces/java/src/org/apache/xerces/impl/xs/XSDDescription.java
  
  Index: XSDDescription.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XSDDescription.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSDDescription.java	22 Jan 2002 23:37:26 -0000	1.1
  +++ XSDDescription.java	9 Feb 2002 20:55:21 -0000	1.2
  @@ -58,6 +58,7 @@
   package org.apache.xerces.impl.xs;
   
   import org.apache.xerces.xni.grammars.XMLGrammarDescription;
  +import org.apache.xerces.util.XMLResourceIdentifierImpl;
   import org.apache.xerces.xni.QName;
   import org.apache.xerces.xni.XMLAttributes;
   
  @@ -65,9 +66,10 @@
    * All information specific to XML Schema grammars.
    *
    * @author Neil Graham, IBM
  - * @version $Id: XSDDescription.java,v 1.1 2002/01/22 23:37:26 sandygao Exp $
  + * @version $Id: XSDDescription.java,v 1.2 2002/02/09 20:55:21 neilg Exp $
    */
  -public class XSDDescription implements XMLGrammarDescription {
  +public class XSDDescription extends XMLResourceIdentifierImpl 
  +		implements XMLGrammarDescription {
       // used to indicate what triggered the call
       /**
        * Indicate that the current schema document is <include>d by another
  @@ -120,34 +122,13 @@
        */
       public final static short CONTEXT_XSITYPE   = 7;
   
  -    /** Returns the public identifier. */
  -    public String getPublicId() {
  -        return null;
  -    }
  -
  -    /** Returns the expanded system identifier. */
  -    public String getExpandedSystemId() {
  -        return null;
  -    }
  -
  -    /** Returns the literal system identifier. */
  -    public String getLiteralSystemId() {
  -        return null;
  -    }
  -
  -    /** <p> Returns the base URI against which the literal SystemId is to be 
  -        resolved. </p> */
  -    public String getBaseSystemId() {
  -        return null;
  -    }
  -
       /**
        * the type of the grammar (e.g., DTD or XSD);
        *  
        * @see org.apache.xerces.xni.grammars.Grammar
        */
       public String getGrammarType() {
  -        return null;
  +        return XMLGrammarDescription.XML_SCHEMA;
       }
   
       /**
  
  
  
  1.11      +18 -5     xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java
  
  Index: SchemaGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaGrammar.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SchemaGrammar.java	29 Jan 2002 01:15:14 -0000	1.10
  +++ SchemaGrammar.java	9 Feb 2002 20:55:21 -0000	1.11
  @@ -64,6 +64,7 @@
   import org.apache.xerces.util.SymbolHash;
   
   import org.apache.xerces.xni.grammars.Grammar;
  +import org.apache.xerces.xni.grammars.XMLGrammarDescription;
   
   import java.util.Hashtable;
   
  @@ -79,7 +80,7 @@
    * @author Sandy Gao, IBM
    * @author Elena Litani, IBM
    *
  - * @version $Id: SchemaGrammar.java,v 1.10 2002/01/29 01:15:14 lehors Exp $
  + * @version $Id: SchemaGrammar.java,v 1.11 2002/02/09 20:55:21 neilg Exp $
    */
   
   public class SchemaGrammar implements Grammar {
  @@ -100,6 +101,9 @@
       //REVISIT: still need to decide on it.
       Hashtable fGlobalTypeDecls;
   
  +    // the XMLGrammarDescription member
  +    XSDDescription fGrammarDescription = null;
  +
       //
       // Constructors
       //
  @@ -109,10 +113,14 @@
        *
        * @param symbolTable
        * @param targetNamespace
  +     * @param grammarDesc the XMLGrammarDescription corresponding to this objec
  +     * 		at the least a systemId should always be known.
        */
  -    public SchemaGrammar(SymbolTable symbolTable, String targetNamespace) {
  +    public SchemaGrammar(SymbolTable symbolTable, String targetNamespace,
  +    		XSDDescription grammarDesc) {
           fSymbolTable = symbolTable;
           fTargetNamespace = targetNamespace;
  +        fGrammarDescription = grammarDesc;
   
           // REVISIT: do we know the numbers of the following global decls
           // when creating this grammar? If so, we can pass the numbers in,
  @@ -140,6 +148,8 @@
       protected SchemaGrammar(SymbolTable symbolTable) {
           fSymbolTable = symbolTable;
           fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
  +	//REVISIT:  will we ever need non-null values in this XSDDescription object?
  +	fGrammarDescription = new XSDDescription();
   
           fGlobalAttrDecls  = new SymbolHash(1);
           fGlobalAttrGrpDecls = new SymbolHash(1);
  @@ -155,9 +165,12 @@
       } // <init>(SymbolTable, boolean)
   
       // Grammar methods
  -    public String getGrammarType() {
  -        return Grammar.XML_SCHEMA;
  -    } // getGrammarType():  String
  +
  +    // return the XMLGrammarDescription corresponding to this
  +    // object
  +    public XMLGrammarDescription getGrammarDescription() {
  +        return fGrammarDescription;
  +    } // getGrammarDescription():  XMLGrammarDescription
       // DTDGrammar methods
       public boolean isNamespaceAware () {
           return true;
  
  
  
  1.23      +13 -2     xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java
  
  Index: XSDHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- XSDHandler.java	4 Feb 2002 20:55:35 -0000	1.22
  +++ XSDHandler.java	9 Feb 2002 20:55:21 -0000	1.23
  @@ -111,7 +111,7 @@
    * schema, other grammars may be constructed as a side-effect.
    *
    * @author Neil Graham, IBM
  - * @version $Id: XSDHandler.java,v 1.22 2002/02/04 20:55:35 edwingo Exp $
  + * @version $Id: XSDHandler.java,v 1.23 2002/02/09 20:55:21 neilg Exp $
    */
   
   public class XSDHandler {
  @@ -503,7 +503,10 @@
           currSchemaInfo.addAllowedNS(currSchemaInfo.fTargetNamespace);
   
           if (fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace) == null) {
  -            SchemaGrammar sg = new SchemaGrammar(fSymbolTable, currSchemaInfo.fTargetNamespace);
  +            // REVISIT:  the grammar bucket should have been called
  +            // already, when we first tried to do the import (not with
  +            // preparse of course).  So this code should be moved!  - NG
  +            SchemaGrammar sg = new SchemaGrammar(fSymbolTable, currSchemaInfo.fTargetNamespace, new XSDDescription());
               fGrammarBucket.putGrammar(sg);
           }
           // we got a grammar of the samenamespace in the bucket, should ignore this one
  @@ -548,6 +551,14 @@
                   currSchemaInfo.addAllowedNS(schemaNamespace);
                   // consciously throw away whether was a duplicate; don't care.
                   // pass the systemId of the current document as the base systemId
  +                // REVISIT:  We must consult the gtrammar bucket, then the gramar
  +                // pool, and only then the entity resolver; this *must* be the
  +                // order.  Therefore, the current sequence is *wrong*, since we
  +                // consult the EntityResolver, only when we call constructTrees
  +                // again consulting Grammar bucket.  So this code needs to be
  +                // reworked - NG
  +                // i.e., we need to create an XSDDescription, ask Grammar
  +                // bucket, ask GrammarPool, then pass that along...
                   newSchemaRoot = getSchema(schemaNamespace, schemaHint, (String)fDoc2SystemId.get(schemaRoot), false, XSDDescription.CONTEXT_IMPORT);
               }
               else if ((localName.equals(SchemaSymbols.ELT_INCLUDE)) ||
  
  
  
  1.2       +2 -3      xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDDescription.java
  
  Index: XMLDTDDescription.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDDescription.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLDTDDescription.java	17 Jan 2002 23:54:59 -0000	1.1
  +++ XMLDTDDescription.java	9 Feb 2002 20:55:21 -0000	1.2
  @@ -58,13 +58,12 @@
   package org.apache.xerces.impl.dtd;
   
   import org.apache.xerces.xni.grammars.XMLGrammarDescription;
  -import org.apache.xerces.xni.grammars.Grammar;
   
   /*
    * All information specific to dTD grammars.  
    * 
    * @author Neil Graham, IBM
  - * @version $Id: XMLDTDDescription.java,v 1.1 2002/01/17 23:54:59 neilg Exp $
  + * @version $Id: XMLDTDDescription.java,v 1.2 2002/02/09 20:55:21 neilg Exp $
    */
   
   public class XMLDTDDescription implements XMLGrammarDescription {
  @@ -103,7 +102,7 @@
       } // getLiteralSystemId():  String
   
       public String getGrammarType () {
  -        return Grammar.XML_DTD;
  +        return XMLGrammarDescription.XML_DTD;
       } // getGrammarType():  String
   
       // return the root name of this DTD
  
  
  
  1.7       +13 -4     xml-xerces/java/src/org/apache/xerces/impl/dtd/AbstractDTDGrammar.java
  
  Index: AbstractDTDGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/AbstractDTDGrammar.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractDTDGrammar.java	29 Jan 2002 01:15:10 -0000	1.6
  +++ AbstractDTDGrammar.java	9 Feb 2002 20:55:21 -0000	1.7
  @@ -62,6 +62,7 @@
   
   import org.apache.xerces.impl.dtd.XMLAttributeDecl;
   import org.apache.xerces.impl.dtd.XMLNotationDecl;
  +import org.apache.xerces.impl.dtd.XMLDTDDescription;
   import org.apache.xerces.impl.dtd.XMLEntityDecl;
   import org.apache.xerces.impl.dtd.XMLSimpleType;
   import org.apache.xerces.impl.dtd.models.CMNode;
  @@ -79,6 +80,7 @@
   
   import org.apache.xerces.xni.QName;
   import org.apache.xerces.xni.grammars.Grammar;
  +import org.apache.xerces.xni.grammars.XMLGrammarDescription;
   
   /**
    * A generic grammar for use in validating XML documents. The Grammar
  @@ -102,7 +104,7 @@
    * @author Eric Ye, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: AbstractDTDGrammar.java,v 1.6 2002/01/29 01:15:10 lehors Exp $
  + * @version $Id: AbstractDTDGrammar.java,v 1.7 2002/02/09 20:55:21 neilg Exp $
    */
   public abstract class AbstractDTDGrammar implements EntityState, Grammar {
   
  @@ -140,6 +142,9 @@
       /** Symbol table. */
       private SymbolTable fSymbolTable;
   
  +    // The XMLDTDDescription with which this Grammar is associated
  +    protected XMLDTDDescription fGrammarDescription = null;
  +
       /** Target namespace of grammar. */
       private String fTargetNamespace;
   
  @@ -274,12 +279,16 @@
       /** Default constructor. */
       protected AbstractDTDGrammar(SymbolTable symbolTable) {
           fSymbolTable = symbolTable;
  +	// are there really situations in which this is a good idea???  - NG
  +	fGrammarDescription = new XMLDTDDescription();
       } // <init>(SymbolTable)
   
       // Grammar methods
  -    public String getGrammarType() {
  -        return Grammar.XML_DTD;
  -    } // getGrammarType():  String
  +
  +    // return the XMLDTDDescription object with which this is associated
  +    public XMLGrammarDescription getGrammarDescription() {
  +        return fGrammarDescription;
  +    } // getGrammarDescription():  XMLGrammarDescription
   
       //
       // Public methods
  
  
  
  1.2       +5 -4      xml-xerces/java/src/org/apache/xerces/parsers/XMLGrammarCachingConfiguration.java
  
  Index: XMLGrammarCachingConfiguration.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/XMLGrammarCachingConfiguration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLGrammarCachingConfiguration.java	7 Feb 2002 22:15:09 -0000	1.1
  +++ XMLGrammarCachingConfiguration.java	9 Feb 2002 20:55:21 -0000	1.2
  @@ -61,6 +61,7 @@
   
   import org.apache.xerces.impl.Constants;
   import org.apache.xerces.xni.grammars.XMLGrammarPool;
  +import org.apache.xerces.xni.grammars.XMLGrammarDescription;
   import org.apache.xerces.xni.grammars.Grammar;
   import org.apache.xerces.impl.Constants;
   import org.apache.xerces.impl.validation.XMLGrammarPoolImpl;
  @@ -103,7 +104,7 @@
    *
    * @author Neil Graham, IBM
    *
  - * @version $Id: XMLGrammarCachingConfiguration.java,v 1.1 2002/02/07 22:15:09 neilg Exp $
  + * @version $Id: XMLGrammarCachingConfiguration.java,v 1.2 2002/02/09 20:55:21 neilg Exp $
    */
   public class XMLGrammarCachingConfiguration 
       extends StandardParserConfiguration {
  @@ -278,7 +279,7 @@
       public Grammar parseGrammar(String type, XMLInputSource
                   is) throws XNIException, IOException {
          // REVISIT:  for now, don't know what to do with DTD's...
  -       if(!type.equals(Grammar.XML_SCHEMA))
  +       if(!type.equals(XMLGrammarDescription.XML_SCHEMA))
               return null;
          if (fSchemaHandler == null) {
              fXSGrammarBucket = new XSGrammarBucket();
  @@ -296,7 +297,7 @@
   
          fXSGrammarBucket.reset();
          // by default, make all XMLGrammarPoolImpl's schema grammars available to fSchemaHandler
  -       SchemaGrammar [] grammars = (SchemaGrammar [])(fGrammarPool.retrieveInitialGrammarSet(Grammar.XML_SCHEMA));
  +       SchemaGrammar [] grammars = (SchemaGrammar [])(fGrammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA));
          for(int i=0; i<grammars.length; i++ )
               fXSGrammarBucket.putGrammar(grammars[i]);
          fSubGroupHandler.reset();
  @@ -312,7 +313,7 @@
              XSConstraints.fullSchemaChecking(fXSGrammarBucket, fSubGroupHandler, fCMBuilder, fErrorReporter);
          }
          // by default, hand it off to the grammar pool
  -       fGrammarPool.cacheGrammars(Grammar.XML_SCHEMA, new Grammar [] {grammar});
  +       fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA, new Grammar [] {grammar});
          return grammar;
   
       }
  
  
  
  1.3       +10 -8     xml-xerces/java/src/org/apache/xerces/xni/grammars/XMLGrammarDescription.java
  
  Index: XMLGrammarDescription.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xni/grammars/XMLGrammarDescription.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLGrammarDescription.java	22 Jan 2002 23:37:26 -0000	1.2
  +++ XMLGrammarDescription.java	9 Feb 2002 20:55:21 -0000	1.3
  @@ -64,16 +64,18 @@
    * physical location and their type. </p>
    *
    * @author Neil Graham, IBM
  - * @version $Id: XMLGrammarDescription.java,v 1.2 2002/01/22 23:37:26 sandygao Exp $
  + * @version $Id: XMLGrammarDescription.java,v 1.3 2002/02/09 20:55:21 neilg Exp $
    */
   public interface XMLGrammarDescription  
           extends XMLResourceIdentifier {
   
  -    /**
  -     * the type of the grammar (e.g., DTD or XSD);
  -     *  
  -     * @see org.apache.xerces.xni.grammars.Grammar
  -     */
  -    public String getGrammarType();
  +    // initial set of grammar constants that some configurations will recognize;user
  +    // components which create and/or recognize other types of grammars may
  +    // certainly use their own constants in place of these (so long as
  +    // their Grammar objects implement this interface).
  +    public static final String XML_SCHEMA = "XSD";
  +    public static final String XML_DTD = "DTD";
   
  -} // XMLGrammarDescription
  +    // return the type of this grammar
  +    public String getGrammarType();
  +} // interface XMLGrammarDescription
  
  
  
  1.3       +4 -10     xml-xerces/java/src/org/apache/xerces/xni/grammars/Grammar.java
  
  Index: Grammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xni/grammars/Grammar.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Grammar.java	28 Jan 2002 19:22:51 -0000	1.2
  +++ Grammar.java	9 Feb 2002 20:55:21 -0000	1.3
  @@ -80,19 +80,13 @@
    * @author Andy Clark, IBM
    * @author Neil Graham, IBM
    *
  - * @version $Id: Grammar.java,v 1.2 2002/01/28 19:22:51 lehors Exp $
  + * @version $Id: Grammar.java,v 1.3 2002/02/09 20:55:21 neilg Exp $
    */
   
   public interface Grammar {
   
  -    // initial set of grammar constants that some configurations will recognize;user
  -    // components which create and/or recognize other types of grammars may
  -    // certainly use their own constants in place of these (so long as
  -    // their Grammar objects implement this interface).
  -    public static final String XML_SCHEMA = "XSD";
  -    public static final String XML_DTD = "DTD";
  -
  -    // return the type of this grammar
  -    public String getGrammarType();
  +    // get the <code>XMLGrammarDescription</code> associated with tihs
  +    // object
  +    public XMLGrammarDescription getGrammarDescription ();
   } // interface Grammar
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org