You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@apache.org on 2002/09/19 23:43:31 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath/types InstanceofExpr.java

mmidy       2002/09/19 14:43:30

  Modified:    java/src/org/apache/xpath/axes Tag: xslt20
                        ExceptPathIterator.java
               java/src/org/apache/xpath/functions Tag: xslt20
                        FuncDistinctNodes.java
               java/src/org/apache/xpath/parser Tag: xslt20 SimpleNode.java
                        XPath.java XPathTreeConstants.java
               java/src/org/apache/xpath/types Tag: xslt20
                        InstanceofExpr.java
  Added:       java/src/org/apache/xpath/axes Tag: xslt20
                        IntersectPathIterator.java
               java/src/org/apache/xpath/functions Tag: xslt20
                        FuncAverage.java
  Log:
  Misc fixes in sequences, instance of, new function Avg,
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +8 -3      xml-xalan/java/src/org/apache/xpath/axes/Attic/ExceptPathIterator.java
  
  Index: ExceptPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/Attic/ExceptPathIterator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ExceptPathIterator.java	6 Sep 2002 15:06:06 -0000	1.1.2.1
  +++ ExceptPathIterator.java	19 Sep 2002 21:43:30 -0000	1.1.2.2
  @@ -218,13 +218,18 @@
     	 accept = super.acceptNode(n);
     	if (accept == DTMIterator.FILTER_ACCEPT)
     	{
  -  		int node = m_iterators[1].getCurrentNode();
  +  	  try
  +  	  {
  +  	    DTMIterator iterator = (DTMIterator)m_iterators[1].clone();
  +  		int node = iterator.getCurrentNode();
     		while (node != DTM.NULL)
     		{
     			if (n ==  node)
     			return DTMIterator.FILTER_SKIP;
  -  			node = m_iterators[1].nextNode();
  -  		} 
  +  			node = iterator.nextNode();
  +  		}
  +  	  }
  +  	  catch (CloneNotSupportedException ex) {} 
     	}
     	return accept;
     }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +145 -0    xml-xalan/java/src/org/apache/xpath/axes/Attic/IntersectPathIterator.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +3 -3      xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDistinctNodes.java
  
  Index: FuncDistinctNodes.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDistinctNodes.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- FuncDistinctNodes.java	18 Sep 2002 14:17:47 -0000	1.1.2.1
  +++ FuncDistinctNodes.java	19 Sep 2002 21:43:30 -0000	1.1.2.2
  @@ -114,15 +114,15 @@
             XObject obj;
            while((obj = seq.next()) != null)
             {
  -            // is this correct, or is it just plain equals??
  -           if (xnss.equalsExistential(obj))
  +            if (xnss.equals(obj))
               {
                 found = true;
                 break;
               }
             }
             if (!found)             
  -              seq.insertItemAt(item, pos++);
  +            seq.insertItemAt(item, pos++);
  +          seq.reset();    
     	    }
     	  }
     	}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +127 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAverage.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1.2.11 +10 -2     xml-xalan/java/src/org/apache/xpath/parser/Attic/SimpleNode.java
  
  Index: SimpleNode.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/parser/Attic/SimpleNode.java,v
  retrieving revision 1.1.2.1.2.10
  retrieving revision 1.1.2.1.2.11
  diff -u -r1.1.2.1.2.10 -r1.1.2.1.2.11
  --- SimpleNode.java	18 Sep 2002 14:17:47 -0000	1.1.2.1.2.10
  +++ SimpleNode.java	19 Sep 2002 21:43:30 -0000	1.1.2.1.2.11
  @@ -10,6 +10,7 @@
   import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.axes.UnionPathIterator;
   import org.apache.xpath.axes.ExceptPathIterator;
  +import org.apache.xpath.axes.IntersectPathIterator;
   import org.apache.xpath.axes.WalkerFactory;
   import org.apache.xpath.functions.*;
   import org.apache.xpath.objects.XDecimal;
  @@ -389,7 +390,10 @@
         new FuncDistinctNodes());
   m_builtInFunctions.put(
         new QName("distinct-values"),
  -      new FuncDistinctValues());
  +      new FuncDistinctValues());      
  +m_builtInFunctions.put(
  +      new QName("avg"),
  +      new FuncAverage());
     }
   
     /**
  @@ -639,7 +643,11 @@
         case XPathTreeConstants.JJTUNIONEXPR :
           newNode = new UnionPathIterator();
           break;
  -      case XPathTreeConstants.JJTINTERSECTEXCEPTEXPR :
  +      case XPathTreeConstants.JJTINTERSECTEXPR :
  +        //newNode = new NonExecutableExpression(p, "JJTUNIONEXPR");
  +        newNode = new IntersectPathIterator();
  +        break;
  +        case XPathTreeConstants.JJTEXCEPTEXPR :
           //newNode = new NonExecutableExpression(p, "JJTUNIONEXPR");
           newNode = new ExceptPathIterator();
           break;
  
  
  
  1.1.2.1.2.1 +7 -2      xml-xalan/java/src/org/apache/xpath/parser/Attic/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/parser/Attic/XPath.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.1.2.1
  diff -u -r1.1.2.1 -r1.1.2.1.2.1
  --- XPath.java	14 Aug 2002 20:07:07 -0000	1.1.2.1
  +++ XPath.java	19 Sep 2002 21:43:30 -0000	1.1.2.1.2.1
  @@ -1380,22 +1380,27 @@
           jj_la1[30] = jj_gen;
           break label_14;
         }
  +      SimpleNode jjtn001;
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
         case Intersect:
           jj_consume_token(Intersect);
             binaryTokenStack.push(token);
  +        UnaryExpr();
  +        jjtn001 = (SimpleNode)SimpleNode.jjtCreate(this, JJTINTERSECTEXPR);
           break;
         case Except:
           jj_consume_token(Except);
             binaryTokenStack.push(token);
  +        UnaryExpr();
  +        jjtn001 = (SimpleNode)SimpleNode.jjtCreate(this, JJTEXCEPTEXPR);
           break;
         default:
           jj_la1[31] = jj_gen;
           jj_consume_token(-1);
           throw new ParseException();
         }
  -      UnaryExpr();
  -                  SimpleNode jjtn001 = (SimpleNode)SimpleNode.jjtCreate(this, JJTINTERSECTEXCEPTEXPR);
  +      //UnaryExpr();
  +                  //SimpleNode jjtn001 = (SimpleNode)SimpleNode.jjtCreate(this, JJTINTERSECTEXCEPTEXPR);
                     boolean jjtc001 = true;
                     jjtree.openNodeScope(jjtn001);
         try {
  
  
  
  1.1.2.1.2.1 +2 -1      xml-xalan/java/src/org/apache/xpath/parser/Attic/XPathTreeConstants.java
  
  Index: XPathTreeConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/parser/Attic/XPathTreeConstants.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.1.2.1
  diff -u -r1.1.2.1 -r1.1.2.1.2.1
  --- XPathTreeConstants.java	14 Aug 2002 20:07:07 -0000	1.1.2.1
  +++ XPathTreeConstants.java	19 Sep 2002 21:43:30 -0000	1.1.2.1.2.1
  @@ -41,7 +41,7 @@
     public int JJTADDITIVEEXPR = 34;
     public int JJTMULTIPLICATIVEEXPR = 35;
     public int JJTUNIONEXPR = 36;
  -  public int JJTINTERSECTEXCEPTEXPR = 37;
  +  public int JJTINTERSECTEXPR = 37;
     public int JJTUNARYEXPR = 38;
     public int JJTMINUS = 39;
     public int JJTPLUS = 40;
  @@ -112,6 +112,7 @@
     public int JJTOCCURRENCEINDICATOR = 105;
     public int JJTMULTIPLY = 106;
     public int JJTQMARK = 107;
  +  public int JJTEXCEPTEXPR = 108;
   
   
     public String[] jjtNodeName = {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1.2.1 +17 -7     xml-xalan/java/src/org/apache/xpath/types/Attic/InstanceofExpr.java
  
  Index: InstanceofExpr.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/types/Attic/InstanceofExpr.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.1.2.1
  diff -u -r1.1.2.1 -r1.1.2.1.2.1
  --- InstanceofExpr.java	14 Aug 2002 20:07:10 -0000	1.1.2.1
  +++ InstanceofExpr.java	19 Sep 2002 21:43:30 -0000	1.1.2.1.2.1
  @@ -112,6 +112,10 @@
     /** SchemaContext is not executable for the moment, so leave it 
      * as a NEE until we figure out what we want to do with it. **/
     private SchemaContext m_schemaContext;
  +  
  +  /** Flag indicating whether expression should be reduced.
  +   *  False if this has more than one child. **/
  +  private boolean m_reduce = true;
   	
     public InstanceofExpr() {
       super();
  @@ -154,8 +158,8 @@
    	
    	XObject value=m_targetExpr.execute(xctxt);
    	
  - 	
  - 	switch(value.getType())
  + 	int type = value.getType();
  + 	switch(type)
    	{
    		case XObject.CLASS_UNKNOWN:
   	 		// If not XSLT type, can't be instance of ...?
  @@ -230,7 +234,7 @@
    			}
    			break;
    	
  - 		case XObject.CLASS_BOOLEAN:
  + 		/*case XObject.CLASS_BOOLEAN:
   			isInstance&=(m_elemOrAttrName==null);
   			isInstance&=(m_schemaTypeName==null);
   			isInstance&=(m_whatToShow==0);
  @@ -254,11 +258,16 @@
   			isInstance&=(m_whatToShow==0);
   			isInstance&=(m_atomicTypeID==XType.STRING);
   			break;
  - 			
  + 		*/	
    		default:
  + 		    isInstance&=(m_elemOrAttrName==null);
  +			isInstance&=(m_schemaTypeName==null);
  +			isInstance&=(m_whatToShow==0);
  +			isInstance&=(m_atomicTypeID==type);
  +			break;
   			// Should never arise
  -			isInstance=false;
  - 			break;
  +			//isInstance=false;
  + 			//break;
    	}
    	
    	return isInstance ? XBoolean.S_TRUE : XBoolean.S_FALSE;
  @@ -296,7 +305,7 @@
      */
     public boolean shouldReduceIfOneChild()
     {
  -    return (m_whatToShow == 0 && m_atomicTypeID == 0) ? true : false;
  +    return (m_whatToShow == 0 && m_atomicTypeID == 0 && m_reduce) ? true : false;
     }
   
   
  @@ -409,6 +418,7 @@
         m_schemaContext = stype.getSchemaContext();
         m_schemaTypeName = stype.getSchemaTypeName();
         m_whatToShow = stype.getWhatToShow();
  +      m_reduce = false;
       }
     }
   
  
  
  

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