001: package net.sf.saxon.instruct;
002:
003: import net.sf.saxon.expr.*;
004: import net.sf.saxon.om.ValueRepresentation;
005: import net.sf.saxon.style.StandardNames;
006: import net.sf.saxon.trans.XPathException;
007: import net.sf.saxon.type.ItemType;
008:
009: import java.util.List;
010:
011: /**
012: * An instruction derived from a xsl:with-param element in the stylesheet. <br>
013: */
014:
015: public class WithParam extends GeneralVariable {
016:
017: public WithParam() {
018: }
019:
020: public int getInstructionNameCode() {
021: return StandardNames.XSL_WITH_PARAM;
022: }
023:
024: public TailCall processLeavingTail(XPathContext context)
025: throws XPathException {
026: // not used
027: return null;
028: }
029:
030: public static void simplify(WithParam[] params, StaticContext env)
031: throws XPathException {
032: for (int i = 0; i < params.length; i++) {
033: Expression select = params[i].getSelectExpression();
034: if (select != null) {
035: params[i].setSelectExpression(select.simplify(env));
036: }
037: }
038: }
039:
040: // public static void analyze(WithParam[] params, StaticContext env, ItemType contextItemType) throws XPathException {
041: // for (int i=0; i<params.length; i++) {
042: // Expression select = params[i].getSelectExpression();
043: // if (select != null) {
044: // params[i].setSelectExpression(select.analyze(env, contextItemType));
045: // }
046: // }
047: // }
048:
049: public static void typeCheck(WithParam[] params, StaticContext env,
050: ItemType contextItemType) throws XPathException {
051: for (int i = 0; i < params.length; i++) {
052: Expression select = params[i].getSelectExpression();
053: if (select != null) {
054: params[i].setSelectExpression(select.typeCheck(env,
055: contextItemType));
056: }
057: }
058: }
059:
060: public static void optimize(Optimizer opt, WithParam[] params,
061: StaticContext env, ItemType contextItemType)
062: throws XPathException {
063: for (int i = 0; i < params.length; i++) {
064: Expression select = params[i].getSelectExpression();
065: if (select != null) {
066: params[i].setSelectExpression(select.optimize(opt, env,
067: contextItemType));
068: }
069: }
070: }
071:
072: /**
073: * Promote the expressions in a set of with-param elements. This is a convenience
074: * method for use by subclasses.
075: */
076:
077: public static void promoteParams(WithParam[] params,
078: PromotionOffer offer) throws XPathException {
079: for (int i = 0; i < params.length; i++) {
080: Expression select = params[i].getSelectExpression();
081: if (select != null) {
082: params[i].setSelectExpression(select.promote(offer));
083: }
084: }
085: }
086:
087: /**
088: * Get the XPath expressions used in an array of WithParam parameters (add them to the supplied list)
089: */
090:
091: public static void getXPathExpressions(WithParam[] params, List list) {
092: for (int i = 0; i < params.length; i++) {
093: Expression exp = params[i].getSelectExpression();
094: if (exp != null) {
095: list.add(exp);
096: }
097: }
098: }
099:
100: /**
101: * Evaluate the variable (method exists only to satisfy the interface)
102: */
103:
104: public ValueRepresentation evaluateVariable(XPathContext context)
105: throws XPathException {
106: throw new UnsupportedOperationException();
107: }
108: }
109:
110: //
111: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
112: // you may not use this file except in compliance with the License. You may obtain a copy of the
113: // License at http://www.mozilla.org/MPL/
114: //
115: // Software distributed under the License is distributed on an "AS IS" basis,
116: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
117: // See the License for the specific language governing rights and limitations under the License.
118: //
119: // The Original Code is: all this file.
120: //
121: // The Initial Developer of the Original Code is Michael H. Kay.
122: //
123: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
124: //
125: // Contributor(s): none.
126: //
|