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/08/10 04:56:33 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/common ContentLeafNameTypeVector.java DFAContentModel.java Grammar.java Makefile

ericye      00/08/09 19:56:33

  Modified:    java/src/org/apache/xerces/framework XMLContentSpec.java
               java/src/org/apache/xerces/validators/common
                        DFAContentModel.java Grammar.java Makefile
  Added:       java/src/org/apache/xerces/validators/common
                        ContentLeafNameTypeVector.java
  Log:
  add new feature: element wildcard any with processContents ='skip' and 'lax'. also fix a bug in traverseComplexType.
  
  Revision  Changes    Path
  1.9       +16 -2     xml-xerces/java/src/org/apache/xerces/framework/XMLContentSpec.java
  
  Index: XMLContentSpec.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/framework/XMLContentSpec.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XMLContentSpec.java	2000/07/20 00:03:02	1.8
  +++ XMLContentSpec.java	2000/08/10 02:56:31	1.9
  @@ -109,7 +109,7 @@
    * string pool index, as the "#PCDATA" leaf is not used in the declarations
    * for element content models.
    *
  - * @version $Id: XMLContentSpec.java,v 1.8 2000/07/20 00:03:02 jeffreyr Exp $
  + * @version $Id: XMLContentSpec.java,v 1.9 2000/08/10 02:56:31 ericye Exp $
    */
   public class XMLContentSpec {
   
  @@ -162,6 +162,20 @@
       /** Represents any local element (XML Schema: ##local). */
       public static final int CONTENTSPECNODE_ANY_LOCAL = 8;
   
  +    /** prcessContent is 'lax' **/
  +    public static final int CONTENTSPECNODE_ANY_LAX = 22;
  +
  +    public static final int CONTENTSPECNODE_ANY_OTHER_LAX = 23;
  +
  +    public static final int CONTENTSPECNODE_ANY_LOCAL_LAX = 24;
  +
  +    /** processContent is 'skip' **/
  +    
  +    public static final int CONTENTSPECNODE_ANY_SKIP = 38;
  +
  +    public static final int CONTENTSPECNODE_ANY_OTHER_SKIP = 39;
  +
  +    public static final int CONTENTSPECNODE_ANY_LOCAL_SKIP = 40;
       //
       // Data
       //
  @@ -278,7 +292,7 @@
   
               // build string
               StringBuffer str = new StringBuffer();
  -            int    parentContentSpecType = contentSpec.type;
  +            int    parentContentSpecType = contentSpec.type & 0x0f;
               int    nextContentSpec;
               switch (parentContentSpecType) {
                   case XMLContentSpec.CONTENTSPECNODE_LEAF: {
  
  
  
  1.13      +24 -7     xml-xerces/java/src/org/apache/xerces/validators/common/DFAContentModel.java
  
  Index: DFAContentModel.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/DFAContentModel.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DFAContentModel.java	2000/07/25 00:20:59	1.12
  +++ DFAContentModel.java	2000/08/10 02:56:32	1.13
  @@ -75,7 +75,7 @@
    * are very constrained in form and easily handled via a special case. 
    * This also makes implementation of this class much easier.
    *
  - * @version $Id: DFAContentModel.java,v 1.12 2000/07/25 00:20:59 andyc Exp $
  + * @version $Id: DFAContentModel.java,v 1.13 2000/08/10 02:56:32 ericye Exp $
    */
   public class DFAContentModel 
       implements XMLContentModel {
  @@ -182,6 +182,8 @@
       /** Array mapping ANY types to the leaf list. */
       private int fLeafListType[] = null;
   
  +    private ContentLeafNameTypeVector fLeafNameTypeVector = null;
  +
       /**
        * The string pool of our parser session. This is set during construction
        * and kept around.
  @@ -379,7 +381,7 @@
               int elemIndex = 0;
               for (; elemIndex < fElemMapSize; elemIndex++)
               {
  -                int type = fElemMapType[elemIndex];
  +                int type = fElemMapType[elemIndex] & 0x0f ;
                   if (type == XMLContentSpec.CONTENTSPECNODE_LEAF) {
                       //System.out.println("fElemMap["+elemIndex+"]: "+fElemMap[elemIndex]);
                       if (fDTD) {
  @@ -498,7 +500,7 @@
               int elemIndex = 0;
               for (; elemIndex < fElemMapSize; elemIndex++)
               {
  -                int type = fElemMapType[elemIndex];
  +                int type = fElemMapType[elemIndex] & 0x0f;
                   if (type == XMLContentSpec.CONTENTSPECNODE_LEAF) {
                       if (comparator.isEquivalentTo(curElem,fElemMap[elemIndex] ) )
                           break;
  @@ -709,6 +711,10 @@
           return -1;
       }
   
  +    public ContentLeafNameTypeVector getContentLeafNameTypeVector() {
  +        return fLeafNameTypeVector;
  +    }
  +
       //
       // Private methods
       //
  @@ -814,6 +820,12 @@
           {
               fElemMap[outIndex] = new QName();
   
  +            if ( (fLeafListType[outIndex] & 0x0f) != 0 ) {
  +                if (fLeafNameTypeVector == null) {
  +                    fLeafNameTypeVector = new ContentLeafNameTypeVector();
  +                }
  +            }
  +
               // Get the current leaf's element index
               final QName element = fLeafList[outIndex].getElement();
   
  @@ -828,7 +840,8 @@
                   }
                   else {
                       if (fElemMap[inIndex].uri == element.uri &&
  -                        fElemMap[inIndex].localpart == element.localpart)
  +                        fElemMap[inIndex].localpart == element.localpart && 
  +                        fElemMapType[inIndex] == fLeafListType[outIndex] )
                           break;
                   }
               }
  @@ -845,6 +858,10 @@
                   fElemMapSize++;
               }
           }
  +        // set up the fLeafNameTypeVector object if there is one.
  +        if (fLeafNameTypeVector != null) {
  +            fLeafNameTypeVector.setValues(fElemMap, fElemMapType, fElemMapSize);
  +        }
   
           //
           //  Next lets create some arrays, some that that hold transient
  @@ -1209,9 +1226,9 @@
           nodeCur.setMaxStates(fLeafCount);
   
           // Recurse as required
  -        if (nodeCur.type() == XMLContentSpec.CONTENTSPECNODE_ANY ||
  -            nodeCur.type() == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL ||
  -            nodeCur.type() == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER) {
  +        if ((nodeCur.type() & 0x0f) == XMLContentSpec.CONTENTSPECNODE_ANY ||
  +            (nodeCur.type() & 0x0f) == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL ||
  +            (nodeCur.type() & 0x0f) == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER) {
               // REVISIT: Don't waste these structures.
               QName qname = new QName(-1, -1, -1, ((CMAny)nodeCur).getURI());
               fLeafList[curIndex] = new CMLeaf(qname, ((CMAny)nodeCur).getPosition());
  
  
  
  1.13      +7 -7      xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java
  
  Index: Grammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Grammar.java	2000/07/26 20:59:59	1.12
  +++ Grammar.java	2000/08/10 02:56:32	1.13
  @@ -69,7 +69,7 @@
   
   
   /**
  - * @version $Id: Grammar.java,v 1.12 2000/07/26 20:59:59 andyc Exp $
  + * @version $Id: Grammar.java,v 1.13 2000/08/10 02:56:32 ericye Exp $
    */
   public class Grammar
   implements XMLContentSpec.Provider {
  @@ -526,9 +526,9 @@
   
           getContentSpec(contentSpecIndex, contentSpec);
   
  -        if (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ANY ||
  -            contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER ||
  -            contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
  +        if ((contentSpec.type & 0x0f ) == XMLContentSpec.CONTENTSPECNODE_ANY ||
  +            (contentSpec.type & 0x0f ) == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER ||
  +            (contentSpec.type & 0x0f ) == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
               // let fall through to build a DFAContentModel
           }
   
  @@ -666,14 +666,14 @@
           // We will build a node at this level for the new tree
           CMNode nodeRet = null;
           getContentSpec(startNode, contentSpec);
  -        if (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ANY) {
  +        if ((contentSpec.type & 0x0f) == XMLContentSpec.CONTENTSPECNODE_ANY) {
               //nodeRet = new CMAny(contentSpec.type, -1, fLeafCount++);
               nodeRet = new CMAny(contentSpec.type, contentSpec.otherValue, fLeafCount++);
           }
  -        else if (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER) {
  +        else if ((contentSpec.type & 0x0f) == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER) {
               nodeRet = new CMAny(contentSpec.type, contentSpec.otherValue, fLeafCount++);
           }
  -        else if (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
  +        else if ((contentSpec.type & 0x0f) == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
               nodeRet = new CMAny(contentSpec.type, -1, fLeafCount++);
           }
           //
  
  
  
  1.5       +1 -0      xml-xerces/java/src/org/apache/xerces/validators/common/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/Makefile,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Makefile	2000/06/15 23:45:16	1.4
  +++ Makefile	2000/08/10 02:56:32	1.5
  @@ -6,6 +6,7 @@
   	CMNode.class\
   	CMStateSet.class\
   	CMUniOp.class\
  +	ContentLeafNameTypeVector.class\
   	DFAContentModel.class\
   	InsertableElementsInfo.class\
   	MixedContentModel.class\
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/validators/common/ContentLeafNameTypeVector.java
  
  Index: ContentLeafNameTypeVector.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.validators.common;
  
  import org.apache.xerces.utils.QName;
  
  /**
   * A light-weight class that stored the leaf names and types from a DFAContentModel
   * @version
   */
  
  public final class ContentLeafNameTypeVector {
      //
      // Data members
      //
  
      public QName[] leafNames = null;
      public int[] leafTypes = null;
      public int leafCount = 0;
  
      //
      // Constructors
      //
  
      public ContentLeafNameTypeVector () {
      }
      
      public ContentLeafNameTypeVector (QName[] names, int[] types, int count) {
          setValues(names, types, count);
      }
  
      public ContentLeafNameTypeVector (ContentLeafNameTypeVector clntv) {
          this(clntv.leafNames, clntv.leafTypes, clntv.leafCount);
      }
  
      //
      // setters
      //
      public void setValues(QName[] names, int[] types, int count) {
          if (count > 0) {
              leafNames = new QName[count];
              leafTypes = new int[count];
              leafCount = count;
  
              System.arraycopy( names, 0, leafNames, 0, count);
              System.arraycopy( types, 0, leafTypes, 0, count);
          }
      }
  
  }