Package net.sf.saxon.event

Examples of net.sf.saxon.event.Receiver


     * @param destination the destination to which the value is to be written
     */

    public void writeXdmValue(XdmValue value, Destination destination) throws SaxonApiException {
        try {
            Receiver out = destination.getReceiver(config);
            out = new NamespaceReducer(out);
            TreeReceiver tree = new TreeReceiver(out);
            tree.open();
            tree.startDocument(0);
            for (Iterator<XdmItem> it = value.iterator(); it.hasNext();) {
View Full Code Here


            } else {
                if (destination == null) {
                    throw new IllegalStateException("No destination supplied");
                }

                Receiver receiver;
                if (destination instanceof Serializer) {
                    receiver = ((Serializer)destination).getReceiver(
                            expression.getExecutable().getConfiguration(),
                            null,
                            expression.getExecutable().getDefaultOutputProperties());
View Full Code Here

    public void run(Destination destination) throws SaxonApiException {
        if (expression.isUpdateQuery()) {
            throw new IllegalStateException("Query is updating");
        }
        try {
            Receiver receiver;
            if (destination instanceof Serializer) {
                receiver = ((Serializer)destination).getReceiver(
                        expression.getExecutable().getConfiguration(),
                        null,
                        expression.getExecutable().getDefaultOutputProperties());
View Full Code Here

                context.getController().recoverableError(e);
            }
            break;

        case Type.DOCUMENT:
            Receiver val = controller.getConfiguration().
                    getDocumentValidator(out,
                                         source.getBaseURI(),
                                         controller.getNamePool(),
                                         validation);
            if (val != out) {
                SequenceReceiver sr = new TreeReceiver(val);
                sr.setConfiguration(controller.getConfiguration());
                c2.setReceiver(sr);
                val = sr;
            }
            val.setConfiguration(controller.getConfiguration());
            val.startDocument(0);
            processChildren(c2);
            val.endDocument();
            break;

        default:
            throw new IllegalArgumentException("Unknown node kind " + source.getNodeKind());
View Full Code Here

            TinyBuilder builder = new TinyBuilder();
            //System.err.println("Build doc " + builder);
            builder.setSizeParameters(treeSizeParameters);
            builder.setLineNumbering(controller.getConfiguration().isLineNumbering());

            Receiver receiver = builder;
            receiver.setSystemId(baseURI);
            receiver.setConfiguration(controller.getConfiguration());
            receiver.open();
            receiver.startDocument(0);
            c2.changeOutputDestination(null,
                    receiver,
                    false,
                    validationAction,
                    schemaType);
            processChildren(c2);
            //c2.resetOutputDestination(old);
            receiver.endDocument();
            receiver.close();
            //System.err.println("End build doc " + builder);

            root = builder.getCurrentDocument();
        }
        return root;
View Full Code Here

        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);
        NodeInfo docType = (NodeInfo) children.next();
        if (docType == null || !("doctype".equals(docType.getLocalPart()))) {
View Full Code Here

        NamePool pool = config.getNamePool();
        TinyBuilder builder = new TinyBuilder();

        NamespaceReducer reducer = new NamespaceReducer();
        reducer.setUnderlyingReceiver(builder);
        Receiver tree = reducer;

        tree.setConfiguration(config);
        builder.setConfiguration(config);
        tree.open();

        int resultSequence = pool.allocate("result", RESULT_NS, "sequence");
        int resultDocument = pool.allocate("result", RESULT_NS, "document");
        int resultElement = pool.allocate("result", RESULT_NS, "element");
        int resultAttribute = pool.allocate("result", RESULT_NS, "attribute");
        int resultText = pool.allocate("result", RESULT_NS, "text");
        int resultComment = pool.allocate("result", RESULT_NS, "comment");
        int resultPI = pool.allocate("result", RESULT_NS, "processing-instruction");
        int resultNamespace = pool.allocate("result", RESULT_NS, "namespace");
        int resultAtomicValue = pool.allocate("result", RESULT_NS, "atomic-value");
        int resultType = pool.allocate("", RESULT_NS, "type");


        tree.startElement(resultSequence, -1, 0, 0);
        tree.namespace(pool.allocateNamespaceCode("result", RESULT_NS), 0);
        tree.startContent();

        while (true) {
            Item next = iterator.next();
            if (next == null) {
                break;
            }
            if (next instanceof NodeInfo) {
                switch (((NodeInfo)next).getNodeKind()) {
                    case Type.DOCUMENT:
                        tree.startElement(resultDocument, -1, 0, 0);
                        tree.startContent();
                        ((DocumentInfo)next).copy(tree, NodeInfo.ALL_NAMESPACES, true, 0);
                        tree.endElement();
                        break;
                    case Type.ELEMENT:
                        tree.startElement(resultElement, -1, 0, 0);
                        tree.startContent();
                        ((NodeInfo)next).copy(tree, NodeInfo.ALL_NAMESPACES, true, 0);
                        tree.endElement();
                        break;
                    case Type.ATTRIBUTE:
                        tree.startElement(resultAttribute, -1, 0, 0);
                        ((NodeInfo)next).copy(tree, NodeInfo.ALL_NAMESPACES, true, 0);
                        tree.startContent();
                        tree.endElement();
                        break;
                    case Type.TEXT:
                        tree.startElement(resultText, -1, 0, 0);
                        tree.startContent();
                        ((NodeInfo)next).copy(tree, NodeInfo.ALL_NAMESPACES, true, 0);
                        tree.endElement();
                        break;
                    case Type.COMMENT:
                        tree.startElement(resultComment, -1, 0, 0);
                        tree.startContent();
                        ((NodeInfo)next).copy(tree, NodeInfo.ALL_NAMESPACES, true, 0);
                        tree.endElement();
                        break;
                    case Type.PROCESSING_INSTRUCTION:
                        tree.startElement(resultPI, -1, 0, 0);
                        tree.startContent();
                        ((NodeInfo)next).copy(tree, NodeInfo.ALL_NAMESPACES, true, 0);
                        tree.endElement();
                        break;
                    case Type.NAMESPACE:
                        tree.startElement(resultNamespace, -1, 0, 0);
                        ((NodeInfo)next).copy(tree, NodeInfo.ALL_NAMESPACES, true, 0);
                        tree.startContent();
                        tree.endElement();
                        break;
                }
            } else {
                tree.startElement(resultAtomicValue, -1, 0, 0);
                tree.attribute(resultType, -1, Type.displayTypeName(next), 0, 0);
                tree.startContent();
                tree.characters(next.getStringValue(), 0, 0);
                tree.endElement();
            }

        }
        tree.endElement();
        tree.close();
        return builder.getCurrentDocument();
    }
View Full Code Here

    public static void serialize(NodeInfo node, Result destination, Properties outputProperties, Configuration config)
    throws XPathException {
        int type = node.getNodeKind();
        if (type==Type.DOCUMENT || type==Type.ELEMENT) {
            DocumentSender sender = new DocumentSender(node);
            Receiver receiver =
                    ResultWrapper.getReceiver(destination,
                                              config,
                                              outputProperties,
                                              null);
            NamespaceReducer reducer = new NamespaceReducer();
View Full Code Here

    */

    public void transform(Source source, Result result)
    throws TransformerException {
        try {
            Receiver receiver = ResultWrapper.getReceiver(
                    result, getConfiguration(), getOutputProperties(), null);
            NamespaceReducer reducer = new NamespaceReducer();
            reducer.setUnderlyingReceiver(receiver);
            new Sender(getConfiguration()).send(source, reducer, true);
        } catch (XPathException err) {
View Full Code Here

                // -- Execute Statement
                ResultSet rs = ps.executeQuery();

                // -- Print out Result
                Receiver out = context.getReceiver();
                String result = "";
                int icol = rs.getMetaData().getColumnCount();
                while(rs.next()) {                            // next row
                    //System.out.print("<- SQL : "+ rowStart);
                    out.startElement(rowCode, -1, locationId, 0);
                    for (int col = 1; col<=icol; col++) {     // next column
                        // Read result from RS only once, because
                        // of JDBC-Specifications
                        result = rs.getString(col);
                        out.startElement(colCode, -1, locationId, 0);
                        if (result!=null) {
                            out.characters(result, locationId, options);
                        }
                        out.endElement();
                    }
                    //System.out.println(rowEnd);
                    out.endElement();
                }
                rs.close();

          if (!connection.getAutoCommit()) {
                    connection.commit();
View Full Code Here

TOP

Related Classes of net.sf.saxon.event.Receiver

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.