morten      01/11/09 05:40:06

  Modified:    java/src/org/apache/xalan/xsltc/compiler Step.java
                        StepPattern.java XSLTC.java xpath.cup xpath.lex
  Log:
  Added support for processing-instruction() with a literal parameter for
  use in node tests in expressions and patterns.
  PR:           bugzilla 2583
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.28      +12 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java
  
  Index: Step.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Step.java 2001/11/06 13:42:04     1.27
  +++ Step.java 2001/11/09 13:40:05     1.28
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Step.java,v 1.27 2001/11/06 13:42:04 morten Exp $
  + * @(#)$Id: Step.java,v 1.28 2001/11/09 13:40:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -78,7 +78,7 @@
       private int _axis;
   
       // A vector of predicates (filters) defined on this step - may be null
  -    private final Vector _predicates;
  +    private Vector _predicates;
   
       // Some simple predicates can be handled by this class (and not by the
       // Predicate class) and will be removed from the above vector as they are
  @@ -138,6 +138,16 @@
        */
       public Vector getPredicates() {
        return _predicates;
  +    }
  +
  +    /**
  +     * Returns the vector containing all predicates for this step.
  +     */
  +    public void addPredicates(Vector predicates) {
  +     if (_predicates == null)
  +         _predicates = predicates;
  +     else
  +         _predicates.addAll(predicates);
       }
   
       /**
  
  
  
  1.12      +11 -6     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java
  
  Index: StepPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StepPattern.java  2001/11/06 13:42:04     1.11
  +++ StepPattern.java  2001/11/09 13:40:05     1.12
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: StepPattern.java,v 1.11 2001/11/06 13:42:04 morten Exp $
  + * @(#)$Id: StepPattern.java,v 1.12 2001/11/09 13:40:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -73,15 +73,15 @@
   
   import org.apache.xalan.xsltc.compiler.util.*;
   
  -final class StepPattern extends RelativePathPattern {
  +class StepPattern extends RelativePathPattern {
   
       private static final int NO_CONTEXT = 0;
       private static final int SIMPLE_CONTEXT = 1;
       private static final int GENERAL_CONTEXT = 2;
   
  -    private final int    _axis;
  -    private final Vector _predicates;
  -    private final int    _nodeType;
  +    protected final int _axis;
  +    protected final int _nodeType;
  +    protected Vector _predicates;
   
       private Step    _step = null;
       private boolean _isEpsilon = false;
  @@ -116,8 +116,13 @@
       public boolean isWildcard() {
        return _isEpsilon && hasPredicates() == false;
       }
  +
  +    public StepPattern setPredicates(Vector predicates) {
  +     _predicates = predicates;
  +     return(this);
  +    }
       
  -    private boolean hasPredicates() {
  +    protected boolean hasPredicates() {
        return _predicates != null && _predicates.size() > 0;
       }
   
  
  
  
  1.33      +2 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
  
  Index: XSLTC.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- XSLTC.java        2001/10/31 07:48:09     1.32
  +++ XSLTC.java        2001/11/09 13:40:05     1.33
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: XSLTC.java,v 1.32 2001/10/31 07:48:09 morten Exp $
  + * @(#)$Id: XSLTC.java,v 1.33 2001/11/09 13:40:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -458,6 +458,7 @@
        final String base  = Util.baseName(className);
        final String noext = Util.noExtName(base); 
        String name  = Util.toJavaName(noext);
  +
        if (_packageName == null)
            _className = name;
        else
  
  
  
  1.28      +42 -7     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
  
  Index: xpath.cup
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- xpath.cup 2001/10/30 08:42:55     1.27
  +++ xpath.cup 2001/11/09 13:40:05     1.28
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: xpath.cup,v 1.27 2001/10/30 08:42:55 morten Exp $
  + * @(#)$Id: xpath.cup,v 1.28 2001/11/09 13:40:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -222,7 +222,7 @@
   terminal PLUS, MINUS, DIV, MOD;
   terminal String Literal;
   terminal String QNAME;
  -terminal ID, KEY, TEXT, NODE, OR, AND, COMMENT, PI, PRECEDINGSIBLING;
  +terminal ID, KEY, TEXT, NODE, OR, AND, COMMENT, PI, PIPARAM, 
PRECEDINGSIBLING;
   terminal SELF, PARENT, CHILD, ATTRIBUTE, ANCESTOR, ANCESTORORSELF, 
DESCENDANT; 
   terminal DESCENDANTORSELF, FOLLOWING, FOLLOWINGSIBLING, NAMESPACE, PRECEDING;
   terminal Double REAL;
  @@ -246,6 +246,7 @@
   non terminal IdKeyPattern IdKeyPattern;
   non terminal Pattern Pattern;
   non terminal Pattern LocationPathPattern;
  +non terminal StepPattern ProcessingInstructionPattern;
   non terminal RelativePathPattern RelativePathPattern;
   non terminal StepPattern StepPattern;
   non terminal Object NodeTestPattern, NameTestPattern;
  @@ -289,6 +290,12 @@
               | SLASH RelativePathPattern:rpp
               {: RESULT = new AbsolutePathPattern(rpp); :}
   
  +            | ProcessingInstructionPattern:pip
  +            {: RESULT = pip; :}
  +
  +         | ProcessingInstructionPattern:pip Predicates:pp
  +            {: RESULT = (ProcessingInstructionPattern)pip.setPredicates(pp); 
:}
  +
               | IdKeyPattern:ikp
               {: RESULT = ikp; :}
   
  @@ -310,6 +317,9 @@
               | KEY LPAREN Literal:l1 COMMA Literal:l2 RPAREN
               {: RESULT = new KeyPattern(l1, l2); :};
   
  +ProcessingInstructionPattern ::= PIPARAM LPAREN Literal:l RPAREN
  +            {: RESULT = new ProcessingInstructionPattern(l); :};
  +
   RelativePathPattern ::= StepPattern:sp
               {: RESULT = sp; :}
   
  @@ -598,15 +608,28 @@
   
   
   Step ::= NodeTest:ntest
  -        {: RESULT = new Step(Axis.CHILD,
  +        {:
  +            if (ntest instanceof Step) {
  +                RESULT = (Step)ntest;
  +            }
  +            else {
  +             RESULT = new Step(Axis.CHILD,
                                parser.findNodeType(Axis.CHILD, ntest, false),
                                null);
  +            }
           :}
   
           | NodeTest:ntest Predicates:pp
  -        {: RESULT = new Step(Axis.CHILD,
  -                             parser.findNodeType(Axis.CHILD, ntest, false),
  -                             pp);
  +        {: 
  +            if (ntest instanceof Step) {
  +                Step step = (Step)ntest;
  +                step.addPredicates(pp);
  +                RESULT = (Step)ntest;
  +            }
  +            else {
  +                RESULT = new Step(Axis.CHILD,
  +                             parser.findNodeType(Axis.CHILD, ntest, 
false),pp);
  +            }
           :}
   
           | AxisSpecifier:axis NodeTest:ntest Predicates:pp
  @@ -748,6 +771,7 @@
   
   FunctionCall ::= FunctionName:fname LPAREN RPAREN
           {: 
  +
             if (fname == parser.getQName("current")) {
               RESULT = new CurrentCall(fname);
          }
  @@ -878,7 +902,6 @@
   
           | Argument:arg COMMA NonemptyArgumentList:argl
           {: argl.insertElementAt(arg, 0); RESULT = argl; :};
  -        /* Is insertElement ok ? */
   
   FunctionName ::= QName:fname
           {:
  @@ -906,6 +929,18 @@
   
           | COMMENT
           {: RESULT = new Integer(NodeTest.COMMENT); :}
  +
  +        | PIPARAM LPAREN Literal:l RPAREN
  +        {:
  +           QName name = parser.getQName("name");
  +           Expression exp = new EqualityExpr(Operators.EQ,
  +                                             new NameCall(name),
  +                                             new LiteralExpr(l));
  +           Vector predicates = new Vector();
  +           predicates.addElement(new Predicate(exp));
  +           RESULT = new Step(Axis.CHILD, NodeTest.PI, predicates);
  +                //RESULT = new Integer(NodeTest.PI);
  +        :}
   
           | PI
           {: RESULT = new Integer(NodeTest.PI); :};
  
  
  
  1.3       +2 -1      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.lex
  
  Index: xpath.lex
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.lex,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- xpath.lex 2001/10/17 10:45:07     1.2
  +++ xpath.lex 2001/11/09 13:40:05     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: xpath.lex,v 1.2 2001/10/17 10:45:07 morten Exp $
  + * @(#)$Id: xpath.lex,v 1.3 2001/11/09 13:40:05 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -112,6 +112,7 @@
   "node"+[ \t\r\n\f]+"()"  { return new Symbol(sym.NODE); }
   "comment()"                 { return new Symbol(sym.COMMENT); }
   "comment"+[ \t\r\n\f]+"()"  { return new Symbol(sym.COMMENT); }
  +"processing-instruction" { return new Symbol(sym.PIPARAM); }
   "processing-instruction()"                { return new Symbol(sym.PI); }
   "processing-instruction"+[ \t\r\n\f]+"()" { return new Symbol(sym.PI); }
   "or"                     { return new Symbol(sym.OR); }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to