morten      01/10/15 02:13:23

  Modified:    java/src/org/apache/xalan/xsltc/compiler Mode.java
                        ParentLocationPath.java Parser.java
                        RelationalExpr.java SyntaxTreeNode.java
               java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java TextOutput.java
  Log:
  A fix for a few regressions.
  PR:           n/a
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.6       +13 -8     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
  
  Index: Mode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Mode.java 2001/08/27 09:07:19     1.5
  +++ Mode.java 2001/10/15 09:13:22     1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Mode.java,v 1.5 2001/08/27 09:07:19 morten Exp $
  + * @(#)$Id: Mode.java,v 1.6 2001/10/15 09:13:22 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -722,16 +722,21 @@
        targets[DOM.ATTRIBUTE] = attrNamespaceHandle;
   
        // Match on processing instruction - default: process next node
  -     targets[DOM.PROCESSING_INSTRUCTION] =
  -         _testSeq[DOM.PROCESSING_INSTRUCTION] != null
  -         ? _testSeq[DOM.PROCESSING_INSTRUCTION]
  -         .compile(classGen, methodGen, ihLoop)
  -         : ihLoop;
  +     InstructionHandle ihPI = ihLoop;
  +     if (_nodeTestSeq != null) ihPI = ihElem;
  +     if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null)
  +         targets[DOM.PROCESSING_INSTRUCTION] =
  +             _testSeq[DOM.PROCESSING_INSTRUCTION].
  +             compile(classGen, methodGen, ihPI);
  +     else
  +         targets[DOM.PROCESSING_INSTRUCTION] = ihPI;
        
        // Match on comments - default: process next node
  +     InstructionHandle ihComment = ihLoop;
  +     if (_nodeTestSeq != null) ihComment = ihElem;
        targets[DOM.COMMENT] = _testSeq[DOM.COMMENT] != null
  -         ? _testSeq[DOM.COMMENT].compile(classGen, methodGen, ihLoop)
  -         : ihLoop;
  +         ? _testSeq[DOM.COMMENT].compile(classGen, methodGen, ihComment)
  +         : ihComment;
   
        // Now compile test sequences for various match patterns:
        for (int i = DOM.NTYPES; i < targets.length; i++) {
  
  
  
  1.12      +14 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java
  
  Index: ParentLocationPath.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ParentLocationPath.java   2001/10/09 15:37:57     1.11
  +++ ParentLocationPath.java   2001/10/15 09:13:22     1.12
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: ParentLocationPath.java,v 1.11 2001/10/09 15:37:57 morten Exp $
  + * @(#)$Id: ParentLocationPath.java,v 1.12 2001/10/15 09:13:22 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -63,10 +63,11 @@
   
   package org.apache.xalan.xsltc.compiler;
   
  +import org.apache.xalan.xsltc.DOM;
  +import org.apache.xalan.xsltc.dom.Axis;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import de.fub.bytecode.generic.*;
   import org.apache.xalan.xsltc.compiler.util.*;
  -import org.apache.xalan.xsltc.dom.Axis;
   
   final class ParentLocationPath extends RelativeLocationPath {
       private Expression _step;
  @@ -175,6 +176,17 @@
             (right == Axis.PRECEDING) ||
             (right == Axis.PRECEDINGSIBLING)))
            return true;
  +
  +     if ((right == Axis.FOLLOWING) && (left == Axis.CHILD)) {
  +         // Special case for '@*/following::*' expressions. The resulting
  +         // iterator is initialised with the parent's first child, and this
  +         // can cause duplicates in the output if the parent has more than
  +         // one attribute that matches the left step.
  +         if (_path instanceof Step) {
  +             int type = ((Step)_path).getNodeType();
  +             if (type == DOM.ATTRIBUTE) return true;
  +         }
  +     }
   
        return false;
       }
  
  
  
  1.27      +20 -11    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Parser.java       2001/09/25 20:38:41     1.26
  +++ Parser.java       2001/10/15 09:13:22     1.27
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Parser.java,v 1.26 2001/09/25 20:38:41 morten Exp $
  + * @(#)$Id: Parser.java,v 1.27 2001/10/15 09:13:22 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -90,7 +90,9 @@
   
       private static final String XSL = "xsl";            // standard prefix
       private static final String TRANSLET = "translet"; // extension prefix
  -    
  +
  +    private Locator _locator = null;
  +
       private XSLTC _xsltc;             // Reference to the compiler object.
       private XPathParser _xpathParser; // Reference to the XPath parser.
       private Vector _errors;           // Contains all compilation errors
  @@ -788,6 +790,8 @@
                node = (SyntaxTreeNode)clazz.newInstance();
                node.setQName(qname);
                node.setParser(this);
  +             if (_locator != null)
  +                 node.setLineNumber(_locator.getLineNumber());
                if (node instanceof Stylesheet) {
                    _xsltc.setStylesheet((Stylesheet)node);
                }
  @@ -842,7 +846,7 @@
        *  @exp    - textual representation of the expression
        */
       public Expression parseExpression(SyntaxTreeNode parent, String exp) {
  -     return (Expression)parseTopLevel(parent, "<EXPRESSION>"+exp, 0, null);
  +     return (Expression)parseTopLevel(parent, "<EXPRESSION>"+exp, null);
       }
   
       /**
  @@ -858,7 +862,7 @@
        // Use the default expression if none was found
           if ((exp.length() == 0) && (def != null)) exp = def;
        // Invoke the XPath parser
  -        return (Expression)parseTopLevel(parent, "<EXPRESSION>"+exp, 0, exp);
  +        return (Expression)parseTopLevel(parent, "<EXPRESSION>"+exp, exp);
       }
   
       /**
  @@ -867,7 +871,7 @@
        *  @exp    - textual representation of the pattern
        */
       public Pattern parsePattern(SyntaxTreeNode parent, String pattern) {
  -     return (Pattern)parseTopLevel(parent, "<PATTERN>"+pattern, 0, pattern);
  +     return (Pattern)parseTopLevel(parent, "<PATTERN>"+pattern, pattern);
       }
   
       /**
  @@ -883,16 +887,18 @@
        // Use the default pattern if none was found
        if ((pattern.length() == 0) && (def != null)) pattern = def;
        // Invoke the XPath parser
  -        return (Pattern)parseTopLevel(parent, "<PATTERN>"+pattern, 0, 
pattern);
  +        return (Pattern)parseTopLevel(parent, "<PATTERN>"+pattern, pattern);
       }
   
       /**
        * Parse an XPath expression or pattern using the generated XPathParser
        * The method will return a Dummy node if the XPath parser fails.
        */
  -    private SyntaxTreeNode parseTopLevel(SyntaxTreeNode parent,
  -                                      String text, int line,
  +    private SyntaxTreeNode parseTopLevel(SyntaxTreeNode parent, String text,
                                         String expression) {
  +     int line = 0;
  +     if (_locator != null) line = _locator.getLineNumber();
  +
        try {
            _xpathParser.setScanner(new XPathLexer(new StringReader(text)));
            Symbol result = _xpathParser.parse(line);
  @@ -901,6 +907,7 @@
                if (node != null) {
                    node.setParser(this);
                    node.setParent(parent);
  +                 node.setLineNumber(line);
                    return node;
                }
            } 
  @@ -929,7 +936,6 @@
        return _errors.size() > 0;
       }
   
  -
       public void internalError() {
        Exception e = new Exception();
        e.printStackTrace();
  @@ -1184,8 +1190,11 @@
       public void skippedEntity(String name) { }
   
       /**
  -     * IGNORED - we already know what the origin of the document is
  +     * Store the document locator to later retrieve line numbers of all
  +     * elements from the stylesheet
        */
  -    public void setDocumentLocator(Locator locator) { }
  +    public void setDocumentLocator(Locator locator) {
  +     _locator = locator;
  +    }
   
   }
  
  
  
  1.9       +24 -5     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java
  
  Index: RelationalExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RelationalExpr.java       2001/09/19 19:25:29     1.8
  +++ RelationalExpr.java       2001/10/15 09:13:22     1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: RelationalExpr.java,v 1.8 2001/09/19 19:25:29 tmiller Exp $
  + * @(#)$Id: RelationalExpr.java,v 1.9 2001/10/15 09:13:22 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -115,16 +115,35 @@
   
        // If one is of reference type, then convert the other too
        if (hasReferenceArgs()) {
  +         Type type = null;
  +         Type typeL = null;
  +         Type typeR = null;
            if (tleft instanceof ReferenceType) {
  -             _right = new CastExpr(_right, Type.Reference);
  +             if (_left instanceof VariableRefBase) {
  +                 VariableRefBase ref = (VariableRefBase)_left;
  +                 VariableBase var = ref.getVariable();
  +                 typeL = var.getType();
  +             }
            }
            if (tright instanceof ReferenceType) {
  -             _left = new CastExpr(_left, Type.Reference);
  +             if (_right instanceof VariableRefBase) {
  +                 VariableRefBase ref = (VariableRefBase)_right;
  +                 VariableBase var = ref.getVariable();
  +                 typeR = var.getType();
  +             }
            }
            // bug fix # 2838 
  -         _right = new CastExpr(_right, Type.Real);
  -            _left = new CastExpr(_left, Type.Real);
  +         if (typeL == null)
  +             type = typeR;
  +         else if (typeR == null)
  +             type = typeL;
  +         else {
  +             type = Type.Real;
  +         }
  +         if (type == null) type = Type.Real;
   
  +         _right = new CastExpr(_right, type);
  +            _left = new CastExpr(_left, type);
            return _type = Type.Boolean;
        }
   
  
  
  
  1.13      +6 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
  
  Index: SyntaxTreeNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SyntaxTreeNode.java       2001/08/27 09:07:19     1.12
  +++ SyntaxTreeNode.java       2001/10/15 09:13:22     1.13
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: SyntaxTreeNode.java,v 1.12 2001/08/27 09:07:19 morten Exp $
  + * @(#)$Id: SyntaxTreeNode.java,v 1.13 2001/10/15 09:13:22 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -88,7 +88,7 @@
       private Parser _parser;
   
       // This node's line number in the input file (not obtainable!!!!)
  -    private final int _line;
  +    private int _line;
   
       // Reference to this node's parent node
       protected SyntaxTreeNode _parent;
  @@ -536,6 +536,10 @@
   
       protected final void indent(int indent) {
        System.out.print(new String(_spaces, 0, indent));
  +    }
  +
  +    public final void setLineNumber(int line) {
  +     _line = line;
       }
   
       public final int getLineNumber() {
  
  
  
  1.27      +2 -11     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- AbstractTranslet.java     2001/10/10 11:50:52     1.26
  +++ AbstractTranslet.java     2001/10/15 09:13:23     1.27
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AbstractTranslet.java,v 1.26 2001/10/10 11:50:52 tmiller Exp $
  + * @(#)$Id: AbstractTranslet.java,v 1.27 2001/10/15 09:13:23 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -473,7 +473,7 @@
       }
   
       /************************************************************************
  -     * Start of an implementation of a multiple output extension.
  +     * Multiple output document extension.
        * See compiler/TransletOutput for actual implementation.
        
************************************************************************/
   
  @@ -524,15 +524,6 @@
        transform(document, document.getIterator(), handler);
       }
        
  -    /**
  -     * Calls transform() with a set of given output handlers
  -     */
  -    public final void transform(DOM document,
  -                             TransletOutputHandler[] handlers) 
  -     throws TransletException {
  -     transform(document, document.getIterator(), handlers[0]);
  -    }
  -
       /**
        * Used by some compiled code as a shortcut for passing strings to the
        * output handler
  
  
  
  1.37      +10 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java
  
  Index: TextOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- TextOutput.java   2001/10/10 11:50:52     1.36
  +++ TextOutput.java   2001/10/15 09:13:23     1.37
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TextOutput.java,v 1.36 2001/10/10 11:50:52 tmiller Exp $
  + * @(#)$Id: TextOutput.java,v 1.37 2001/10/15 09:13:23 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -800,9 +800,17 @@
            if (_startTagOpen) closeStartTag();
            if (_cdataTagOpen) closeCDATA();
   
  +         // Handle document type declaration (only HTML at this point)
  +         if ((_lexHandler != null) && (_outputType == HTML)) {
  +             if ((_doctypeSystem != null) || (_doctypePublic != null))
  +                 _lexHandler.startDTD("HTML",_doctypePublic,_doctypeSystem);
  +             _lexHandler = null;
  +         }
  +
            // Pass the processing instruction to the SAX handler
               _saxHandler.processingInstruction(target, data);
  -        } catch (SAXException e) {
  +        }
  +     catch (SAXException e) {
               throw new TransletException(e);
           }
       }
  
  
  

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

Reply via email to