Package net.sf.saxon.expr

Examples of net.sf.saxon.expr.Expression


                        null,
                        inheritNamespaces,
                        schemaType,
                        validation);
                inst.setBaseURI(getBaseURI());
                Expression content = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);

                if (attributeSets != null) {
                    UseAttributeSets use = new UseAttributeSets(attributeSets);
                    if (content == null) {
                        content = use;
                    } else {
                        content = Block.makeBlock(use, content);
                        content.setLocationId(
                                    allocateLocationId(getSystemId(), getLineNumber()));
                    }
                }
                if (content == null) {
                    content = new Literal(EmptySequence.getInstance());
                }
                inst.setContentExpression(content);
                return inst;
            }
        } else {
            // if the namespace URI must be deduced at run-time from the element name
            // prefix, we need to save the namespace context of the instruction

            if (namespace == null) {
                nsContext = makeNamespaceContext();
            }
        }

        ComputedElement inst = new ComputedElement(elementName,
                namespace,
                nsContext,
                //(nsContext==null ? null : nsContext.getURIForPrefix("", true)),
                schemaType,
                validation,
                inheritNamespaces,
                false);
        Expression content = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
        if (attributeSets != null) {
            UseAttributeSets use = new UseAttributeSets(attributeSets);
            if (content == null) {
                content = use;
            } else {
                content = Block.makeBlock(use, content);
                content.setLocationId(
                            allocateLocationId(getSystemId(), getLineNumber()));
            }
        }
        if (content == null) {
            content = new Literal(EmptySequence.getInstance());
View Full Code Here


    public XPathExpressionImpl createExpression(String expression) throws net.sf.saxon.trans.XPathException {
        return createExpressionInternal(expression);
    }

    private XPathExpressionImpl createExpressionInternal(String expression) throws net.sf.saxon.trans.XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext, 0, -1, 1, false);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getConfiguration().makeSlotManager();
        ExpressionTool.allocateSlots(exp, 0, map);
        exp.setContainer(staticContext);
        XPathExpressionImpl xpe = new XPathExpressionImpl(exp, getExecutable());
        xpe.setStackFrameMap(map);
        if (contextNode != null) {
            xpe.privatelySetContextNode(contextNode);
        }
View Full Code Here

     * </ul>
     * @deprecated since Saxon 8.9 - use the various method defined in the JAXP interface definition
    */

    public List evaluate(String expression) throws net.sf.saxon.trans.XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext,0,-1,1, false);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getConfiguration().makeSlotManager();
        ExpressionTool.allocateSlots(exp, 0, map);
        XPathContextMajor context = new XPathContextMajor(contextNode, staticContext.getExecutable());
        context.openStackFrame(map);
        SequenceIterator iterator = exp.iterate(context);
        ArrayList list = new ArrayList(20);
        while (true) {
            Item item = iterator.next();
            if (item == null) {
                return list;
View Full Code Here

    * the evaluate() method
     * @deprecated since Saxon 8.9 - use the methods defined in the JAXP interface
    */

    public Object evaluateSingle(String expression) throws net.sf.saxon.trans.XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext,0,-1,1, false);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getConfiguration().makeSlotManager();
        ExpressionTool.allocateSlots(exp, 0, map);
        XPathContextMajor context = new XPathContextMajor(contextNode, staticContext.getExecutable());
        context.openStackFrame(map);
        SequenceIterator iterator = exp.iterate(context);
        Item item = iterator.next();
        if (item == null) {
            return null;
        } else {
            return Value.convertToJava(item);
View Full Code Here

*/

public class StringJoin extends SystemFunction {

    public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException {
        Expression exp = super.optimize(visitor, contextItemType);
        if (exp instanceof StringJoin) {
            return ((StringJoin)exp).simplifySingleton();
        } else {
            return exp;
        }
View Full Code Here

    * This is a pure function so it can be simplified in advance if the arguments are known
     * @param visitor an expression visitor
     */

    public Expression simplify(ExpressionVisitor visitor) throws XPathException {
        Expression e = simplifyArguments(visitor);
        if (e == this) {
            maybePrecompile(visitor);
        }
        return e;
    }
View Full Code Here

     *          if an error is discovered during this phase
     *          (typically a type error)
     */

    public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException {
        Expression e = super.optimize(visitor, contextItemType);
        // try once again to compile the regular expression once if possible
        // (used when the regex has been identified as a constant as a result of earlier rewrites)
        if (e == this) {
            maybePrecompile(visitor);
        }
View Full Code Here

            }
        }
    }

    public Expression compile(Executable exec) throws TransformerConfigurationException {
        Expression expr = new NumberInstruction ( select,
                                        level,
                                        count,
                                        from,
                                        value,
                                        format,
View Full Code Here

    public SequenceIterator rawIterator() throws XPathException {
        XPathContextMajor context = new XPathContextMajor(contextNode, configuration);
        context.openStackFrame(stackFrameMap);
        SequenceIterator iterator = expression.iterate(context);
        if (sortKey != null) {
            Expression key = sortKey.expression;
            if (key.getItemType() instanceof NodeTest) {
                key = new Atomizer(key);
            }

            FixedSortKeyDefinition[] sk = new FixedSortKeyDefinition[1];
View Full Code Here

    public Expression compile(Executable exec) throws TransformerConfigurationException {

        Block block = new Block();
        compileChildren(exec, block, true);
        Expression exp = null;
        try {
            exp = block.simplify(getStaticContext());
        } catch (XPathException e) {
            compileError(e);
        }
        try {
            if (requiredType != null) {
                RoleLocator role =
                        new RoleLocator(RoleLocator.TEMPLATE_RESULT, diagnosticId, 0);
                exp = TypeChecker.staticTypeCheck(exp, requiredType, false, role, getStaticContext());
            }
        } catch (XPathException err) {
            compileError(err);
        }

        compiledTemplate.init ( getObjectFingerprint(),
                                getPrecedence(),
                                getMinImportPrecedence());

        if (getConfiguration().getTraceListener() != null) {
            TraceWrapper trace = new TraceInstruction(exp, this);
            trace.setLocationId(allocateLocationId(getSystemId(), getLineNumber()));
            trace.setParentExpression(compiledTemplate);
            exp = trace;
        }

        compiledTemplate.setBody(exp);
        compiledTemplate.setStackFrameMap(stackFrameMap);
        compiledTemplate.setExecutable(getExecutable());
        compiledTemplate.setSystemId(getSystemId());
        compiledTemplate.setLineNumber(getLineNumber());

        ItemType contextItemType = Type.ITEM_TYPE;
        if (getObjectFingerprint() == -1) {
            // the template can't be called by name, so the context item must match the match pattern
            contextItemType = match.getNodeTest();
        }


        try {
            Expression exp2 = exp.analyze(staticContext, contextItemType);
            if (exp != exp2) {
                compiledTemplate.setBody(exp2);
            }
        } catch (XPathException e) {
            compileError(e);
View Full Code Here

TOP

Related Classes of net.sf.saxon.expr.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.