Package net.sf.saxon.expr

Examples of net.sf.saxon.expr.XPathContext


            return StringValue.EMPTY_STRING;
        }

        try {
            StringWriter result = new StringWriter();
            XPathContext c2 = c.newMinorContext();
        c.setOriginatingConstructType(Location.SAXON_SERIALIZE);

            c2.changeOutputDestination(outputProperties,
                                               new StreamResult(result),
                                               false,
                                               Validation.PRESERVE,
                                               null);
            SequenceReceiver out = c2.getReceiver();
            out.open();
            node.copy(out, NodeInfo.ALL_NAMESPACES, true, locationId);
            out.close();
            return new StringValue(result.toString());
        } catch (XPathException err) {
View Full Code Here


    }


    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        XPathContext c2 = context.newMinorContext();
        c2.setOrigin(this);
        SequenceReceiver out = c2.getReceiver();
        TinyBuilder builder = new TinyBuilder();
        Receiver receiver = builder;
        receiver.setConfiguration(controller.getConfiguration());
        receiver.open();

        c2.changeOutputDestination(null, receiver, false, Validation.PRESERVE, null);
        processChildren(c2);
        receiver.close();
        DocumentInfo dtdRoot = builder.getCurrentDocument();

        SequenceIterator children = dtdRoot.iterateAxis(Axis.CHILD);
View Full Code Here

        }

        nodeKeys = new Object[allocated * recordSize];
        count = 0;

        XPathContext c2 = context.newMinorContext();
        c2.setOriginatingConstructType(Location.SORT_KEY);
        c2.setCurrentIterator(base);

        // initialise the array with data

        while (true) {
            Item item = base.next();
View Full Code Here

        return list.iterator();
    }

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        XPathContext c2 = context.newMinorContext();
        c2.setOrigin(this);

        Result result;
        OutputURIResolver resolver = null;

        if (href == null) {
            result = controller.getPrincipalResult();
        } else {
            try {
                resolver = controller.getOutputURIResolver();

                String hrefValue = href.evaluateAsString(context);
                result = resolver.resolve(hrefValue, controller.getPrincipalResultURI());
                if (result == null) {
                    resolver = StandardOutputResolver.getInstance();
                    result = resolver.resolve(hrefValue, controller.getPrincipalResultURI());
                }
            } catch (TransformerException e) {
                throw XPathException.wrap(e);
            }
        }

        boolean timing = controller.getConfiguration().isTiming();
        if (timing) {
            String dest = result.getSystemId();
            if (dest == null) {
                if (result instanceof StreamResult) {
                    dest = "anonymous output stream";
                } else if (result instanceof SAXResult) {
                    dest = "SAX2 ContentHandler";
                } else if (result instanceof DOMResult) {
                    dest = "DOM tree";
                } else {
                    dest = result.getClass().getName();
                }
            }
            System.err.println("Writing to " + dest);
        }

        Properties props = outputProperties;
        if (serializationAttributes.size() > 0) {
            props = new Properties(outputProperties);
            final NamePool namePool = context.getController().getNamePool();
            for (Iterator it = serializationAttributes.keySet().iterator(); it.hasNext();) {
                Integer key = (Integer) it.next();
                Expression exp = (Expression) serializationAttributes.get(key);
                String value = exp.evaluateAsString(context);
                try {
                    setSerializationProperty(props, key.intValue(), value, namePool, nsResolver);
                } catch (DynamicError e) {
                    e.setXPathContext(context);
                    e.setLocator(getSourceLocator());
                    throw e;
                }
            }
        }
        String nextInChain = outputProperties.getProperty(SaxonOutputKeys.NEXT_IN_CHAIN);
        if (nextInChain != null) {
            try {
                result = controller.prepareNextStylesheet(nextInChain, baseURI, result);
            } catch (TransformerException e) {
                throw XPathException.wrap(e);
            }
        }

        c2.changeOutputDestination(props,
                result,
                true,
                validationAction,
                schemaType);
        processChildren(c2);
        SequenceReceiver out = c2.getReceiver();
        out.close();
        if (resolver != null) {
            try {
                resolver.close(result);
            } catch (TransformerException e) {
View Full Code Here

      * or more groups, one for each value of the grouping key.
     */

    private void buildIndexedGroups() throws XPathException {
        HashMap index = new HashMap();
        XPathContext c2 = keyContext.newMinorContext();
        c2.setCurrentIterator(population);
        c2.setOriginatingConstructType(Location.GROUPING_KEY);
        while (true) {
            Item item = population.next();
            if (item==null) {
                break;
            }
View Full Code Here

    public int position() {
        return position;
    }

    public SequenceIterator getAnother() throws XPathException {
        XPathContext c2 = keyContext.newMinorContext();
        c2.setOriginatingConstructType(Location.GROUPING_KEY);
        return new GroupByIterator(population, keyExpression, c2, collator);
    }
View Full Code Here

    public int position() {
        return position;
    }

    public SequenceIterator getAnother() throws XPathException {
        XPathContext c2 = keyContext.newMinorContext();
        c2.setOrigin(keyContext.getOrigin());
        return new GroupAdjacentIterator(population, keyExpression, c2, collator);
    }
View Full Code Here

        SequenceIterator iter = select.iterate(context);
        if (iter instanceof EmptyIterator) {
            return iter;
        }
        XPathContext xpc = context.newMinorContext();
        xpc.setOrigin(this);

        FixedSortKeyDefinition[] reducedSortKeys;
        if (fixedSortKeys != null) {
            reducedSortKeys = fixedSortKeys;
        } else {
View Full Code Here

                } else {
                    return "";
                }
            }
        } else {
            XPathContext context = null;
            if (err instanceof DynamicError) {
                context = ((DynamicError)err).getXPathContext();
            }
            return getLocationMessage(loc, context);
        }
View Full Code Here

                loc = err.getLocator();
            } else {
                return "";
            }
        }
        XPathContext context = null;
        if (err instanceof XPathException) {
            context = ((XPathException)err).getXPathContext();
        }
        return getLocationMessage(loc, context);
    }
View Full Code Here

TOP

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

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.