Package org.pdf4j.saxon.expr

Examples of org.pdf4j.saxon.expr.Expression


        boolean needsNamespaceContext = (formatExpression != null);
        NameChecker checker = exec.getConfiguration().getNameChecker();
        NamespaceResolver namespaceResolver = getStaticContext().getNamespaceResolver();
        for (IntIterator it=serializationAttributes.keyIterator(); it.hasNext();) {
            int fp = it.next();
            Expression exp = (Expression)serializationAttributes.get(fp);
            if (exp instanceof StringLiteral) {
                String s = ((StringLiteral)exp).getStringValue();
                String lname = getNamePool().getLocalName(fp);
                String uri = getNamePool().getURI(fp);
                try {

                    ResultDocument.setSerializationProperty(localProps, uri, lname, s,
                            namespaceResolver, false, checker);
                    fixed.add(fp);
                } catch (XPathException e) {
                    if (NamespaceConstant.SAXON.equals(e.getErrorCodeNamespace())) {
                        compileWarning(e.getMessage(), e.getErrorCodeLocalPart());
                    } else {
                        compileError(e);
                    }
                }
            } else {
                String lname = getNamePool().getLocalName(fp);
                if (lname.equals("method") || lname.equals("cdata-section-elements") ||
                        lname.equals("suppress-indentation")) {
                    needsNamespaceContext = true;
                }
            }
        }
        for (IntIterator it=fixed.iterator(); it.hasNext();) {
            serializationAttributes.remove(it.next());
        }

        ResultDocument inst = new ResultDocument(globalProps,
                                              localProps,
                                              href,
                                              formatExpression,
                                              getBaseURI(),
                                              validationAction,
                                              schemaType,
                                              serializationAttributes,
                                              (needsNamespaceContext ? namespaceResolver : null));

        Expression b = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
        if (b == null) {
            b = new Literal(EmptySequence.getInstance());
        }
        inst.setContent(b);
        return inst;
View Full Code Here


     */

    public Expression bind(StructuredQName functionName, Expression[] staticArgs, StaticContext env) throws XPathException {
        final String uri = functionName.getNamespaceURI();
        if (namespaces.contains(uri)) {
            Expression call = baseLibrary.bind(functionName, staticArgs, env);
            if (call != null) {
                // Check that the result type and all the argument types are in the static context of the
                // calling module
                XQueryFunction def = baseLibrary.getDeclaration(functionName, staticArgs);
                importingModule.checkImportedFunctionSignature(def);
View Full Code Here

    public Expression compile(Executable exec) throws XPathException {

        DocumentInstr inst = new DocumentInstr(false, null, getBaseURI());
        inst.setValidationMode(validationAction);
        inst.setSchemaType(schemaType);
        Expression b = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
        if (b == null) {
            b = Literal.makeEmptySequence();
        }
        inst.setContentExpression(b);
        return inst;
View Full Code Here

    public Expression bind(StructuredQName functionName, Expression[] staticArgs, StaticContext env)
            throws XPathException {
        for (Iterator it=libraryList.iterator(); it.hasNext();) {
            FunctionLibrary lib = (FunctionLibrary)it.next();
            Expression func = lib.bind(functionName, staticArgs, env);
            if (func != null) {
                return func;
            }
        }
        return null;
View Full Code Here

     * @return a Procedure object representing the compiled attribute set
     * @throws XPathException if a failure is detected
     */
    public Expression compile(Executable exec) throws XPathException {
        if (referenceCount > 0 ) {
            Expression body = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
            if (body == null) {
                body = Literal.makeEmptySequence();
            }

            try {

                ExpressionVisitor visitor = makeExpressionVisitor();
                body = visitor.simplify(body);
                if (getConfiguration().isCompileWithTracing()) {
                    TraceWrapper trace = new TraceInstruction(body, this);
                    trace.setLocationId(allocateLocationId(getSystemId(), getLineNumber()));
                    trace.setContainer(procedure);
                    body = trace;
                }

                procedure.setUseAttributeSets(useAttributeSets);
                procedure.setName(getObjectName());
                procedure.setBody(body);
                procedure.setSystemId(getSystemId());
                procedure.setLineNumber(getLineNumber());
                procedure.setExecutable(exec);

                Expression exp2 = body.optimize(visitor, AnyItemType.getInstance());
                if (body != exp2) {
                    procedure.setBody(exp2);
                    body = exp2;
                }

View Full Code Here

        }
    }

    public Expression compile(Executable exec) throws XPathException {
        SortKeyDefinition[] sortKeys = makeSortKeys();
        Expression sortedSequence = select;
        if (sortKeys != null) {
            sortedSequence = new SortExpression(select, sortKeys);
        }

        Expression block = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
        if (block == null) {
            // body of for-each is empty: it's a no-op.
            return Literal.makeEmptySequence();
        }
        try {
View Full Code Here

    * @throws XPathException if the syntax of the expression is wrong, or if it references namespaces,
    * variables, or functions that have not been declared.
    */

    public XPathExpression createExpression(String expression) throws XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext, 0, -1, 1, false);
        exp.setContainer(staticContext);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        exp = visitor.optimize(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getStackFrameMap();
View Full Code Here

    public Expression compile(Executable exec) throws XPathException {
        SortKeyDefinition[] sortKeys = makeSortKeys();
        if (select != null) {
            return new SortExpression(select, sortKeys);
        } else {
            Expression body = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
            if (body == null) {
                body = Literal.makeEmptySequence();
            }
            try {
                return new SortExpression(makeExpressionVisitor().simplify(body), sortKeys);
View Full Code Here

    }

    public Expression compile(Executable exec) throws XPathException {
        SequenceIterator children = iterateAxis(Axis.CHILD);
        List nonFinallyChildren = new ArrayList();
        Expression finallyExp = null;
        while (true) {
            NodeInfo node = (NodeInfo)children.next();
            if (node == null) {
                break;
            } else if (node instanceof SaxonFinally) {
                finallyExp = ((SaxonFinally)node).compile(exec);
            } else {
                nonFinallyChildren.add(node);
            }
        }
        Expression block = compileSequenceConstructor(exec, new ListIterator(nonFinallyChildren), true);
        if (block == null) {
            // body of saxon:iterate is empty: it's a no-op.
            return Literal.makeEmptySequence();
        }
        try {
View Full Code Here

        return new SaxonXQExpressionContext(expression);
    }

    public XQSequenceType getStaticResultType() throws XQException {
        checkNotClosed();
        Expression exp = expression.getExpression();    // unwrap two layers!
        ItemType itemType = exp.getItemType(connection.getConfiguration().getTypeHierarchy());
        int cardinality = exp.getCardinality();
        SequenceType staticType = SequenceType.makeSequenceType(itemType, cardinality);
        return new SaxonXQSequenceType(staticType, connection.getConfiguration());
    }
View Full Code Here

TOP

Related Classes of org.pdf4j.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.