Project

Profile

Help

Revision 4afaf252

Added by Michael Kay about 3 years ago

Fix bug 3934 (streaming)

View differences:

latest9.9/hej/net/sf/saxon/expr/instruct/Message.java
10 10
import net.sf.saxon.Configuration;
11 11
import net.sf.saxon.event.*;
12 12
import net.sf.saxon.expr.*;
13
import net.sf.saxon.expr.parser.ExplicitLocation;
14
import net.sf.saxon.expr.parser.ExpressionTool;
15
import net.sf.saxon.expr.parser.Location;
16
import net.sf.saxon.expr.parser.RebindingMap;
13
import net.sf.saxon.expr.parser.*;
17 14
import net.sf.saxon.lib.NamespaceConstant;
18 15
import net.sf.saxon.lib.SerializerFactory;
19 16
import net.sf.saxon.lib.StandardErrorListener;
......
153 150
        return true;
154 151
    }
155 152

  
153
    /**
154
     * Perform optimisation of an expression and its subexpressions. This is the third and final
155
     * phase of static optimization.
156
     * <p>This method is called after all references to functions and variables have been resolved
157
     * to the declaration of the function or variable, and after all type checking has been done.</p>
158
     *
159
     * @param visitor     an expression visitor
160
     * @param contextInfo the static type of "." at the point where this expression is invoked.
161
     *                    The parameter is set to null if it is known statically that the context item will be undefined.
162
     *                    If the type of the context item is not known statically, the argument is set to
163
     *                    {@link Type#ITEM_TYPE}
164
     * @return the original expression, rewritten if appropriate to optimize execution
165
     * @throws XPathException if an error is discovered during this phase
166
     *                        (typically a type error)
167
     */
168
    @Override
169
    public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException {
170
        Expression e = super.optimize(visitor, contextInfo);
171
        if (e != this) {
172
            return e;
173
        }
174
//        if (visitor.isOptimizeForStreaming()) {
175
//            DocumentInstr doc = new DocumentInstr(false, null);
176
//            doc.setContentExpression(getSelect());
177
//            setSelect(doc);
178
//        }
179
        return this;
180
    }
156 181

  
157 182
    public TailCall processLeavingTail(XPathContext context) throws XPathException {
158 183
        XsltController controller = (XsltController)context.getController();
latest9.9/hej/net/sf/saxon/style/XSLAssert.java
49 49
        return true;
50 50
    }
51 51

  
52
    public void prepareAttributes() throws XPathException {
52
    public void prepareAttributes() {
53 53

  
54 54
        String testAtt = null;
55 55
        String selectAtt = null;
......
58 58

  
59 59
        for (int a = 0; a < atts.getLength(); a++) {
60 60
            String f = atts.getQName(a);
61
            if (f.equals("test")) {
62
                testAtt = atts.getValue(a);
63
                test = makeExpression(testAtt, a);
64
            } else if (f.equals("select")) {
65
                selectAtt = atts.getValue(a);
66
                select = makeExpression(selectAtt, a);
67
            } else if (f.equals("error-code")) {
68
                errorCodeAtt = atts.getValue(a);
69
                errorCode = makeAttributeValueTemplate(errorCodeAtt, a);
70
            } else {
71
                checkUnknownAttribute(atts.getNodeName(a));
61
            switch (f) {
62
                case "test":
63
                    testAtt = atts.getValue(a);
64
                    test = makeExpression(testAtt, a);
65
                    break;
66
                case "select":
67
                    selectAtt = atts.getValue(a);
68
                    select = makeExpression(selectAtt, a);
69
                    break;
70
                case "error-code":
71
                    errorCodeAtt = atts.getValue(a);
72
                    errorCode = makeAttributeValueTemplate(errorCodeAtt, a);
73
                    break;
74
                default:
75
                    checkUnknownAttribute(atts.getNodeName(a));
76
                    break;
72 77
            }
73 78
        }
74 79

  
latest9.9/hej/net/sf/saxon/style/XSLMessage.java
58 58

  
59 59
        for (int a = 0; a < atts.getLength(); a++) {
60 60
            String f = atts.getQName(a);
61
            if (f.equals("terminate")) {
62
                terminateAtt = Whitespace.trim(atts.getValue(a));
63
                terminate = makeAttributeValueTemplate(terminateAtt, a);
64
            } else if (f.equals("select")) {
65
                selectAtt = atts.getValue(a);
66
                select = makeExpression(selectAtt, a);
67
            } else if (f.equals("error-code")) {
68
                errorCodeAtt = atts.getValue(a);
69
                errorCode = makeAttributeValueTemplate(errorCodeAtt, a);
70
            } else if (atts.getURI(a).equals(NamespaceConstant.SAXON) && atts.getLocalName(a).equals("time")) {
71
                boolean timed = processBooleanAttribute("saxon:time", atts.getValue(a));
72
                if (timed) {
73
                    timer = makeExpression(
74
                            "format-dateTime(Q{http://saxon.sf.net/}timestamp(),'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f,3-3] - ')", a);
75
                }
76
            } else {
77
                checkUnknownAttribute(atts.getNodeName(a));
61
            switch (f) {
62
                case "terminate":
63
                    terminateAtt = Whitespace.trim(atts.getValue(a));
64
                    terminate = makeAttributeValueTemplate(terminateAtt, a);
65
                    break;
66
                case "select":
67
                    selectAtt = atts.getValue(a);
68
                    select = makeExpression(selectAtt, a);
69
                    break;
70
                case "error-code":
71
                    errorCodeAtt = atts.getValue(a);
72
                    errorCode = makeAttributeValueTemplate(errorCodeAtt, a);
73
                    break;
74
                default:
75
                    if (atts.getURI(a).equals(NamespaceConstant.SAXON) && atts.getLocalName(a).equals("time")) {
76
                        boolean timed = processBooleanAttribute("saxon:time", atts.getValue(a));
77
                        if (timed) {
78
                            timer = makeExpression(
79
                                    "format-dateTime(Q{http://saxon.sf.net/}timestamp(),'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f,3-3] - ')", a);
80
                        }
81
                    } else {
82
                        checkUnknownAttribute(atts.getNodeName(a));
83
                    }
84
                    break;
78 85
            }
79 86
        }
80 87

  

Also available in: Unified diff