Examples of emit()


Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

    @Override
    public String toString() {
        final StringWriter sw = new StringWriter();
        final SAXSerializer ser = new SAXSerializer(new SAXWriter(sw), sw);
        try {
            ser.emit(this);
        } catch (XQueryException e) {
            return "failed at " + e.getStackTrace()[1] + "!\n" + e.getMessage();
        }
        return sw.toString();
    }
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

        StringWriter sw = new StringWriter();
        SAXWriter saxwriter = new SAXWriter(sw);
        saxwriter.setXMLDeclaration(false);
        SAXSerializer ser = new SAXSerializer(saxwriter, sw);
        try {
            ser.emit(this);
        } catch (XQueryException e) {
            return "failed at " + e.getStackTrace()[1] + ".\n" + e.getMessage();
        }
        return sw.toString();
    }
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

        // execute              
        FastMultiByteArrayOutputStream out = new FastMultiByteArrayOutputStream();
        SAXWriter writer = new SAXWriter(out, "UTF-8");
        final Serializer ser = new SAXSerializer(writer);
        Sequence<? extends Item> result = processor.execute(mod);
        ser.emit(result);
        writer.flush();

        System.err.println(sw);
        return out.toString();
    }
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

        // execute
        FastMultiByteArrayOutputStream out = new FastMultiByteArrayOutputStream();
        SAXWriter writer = new SAXWriter(out, "UTF-8");
        final Serializer ser = new SAXSerializer(writer);
        Sequence<? extends Item> result = processor.execute(mod);
        ser.emit(result);
        //processor.execute(mod, ser);
        writer.flush();

        System.err.println(sw);
        return out.toString();
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

        final StringWriter sw = new StringWriter();
        final SAXWriter writer = new SAXWriter(sw);
        writer.setXMLDeclaration(false);
        final SAXSerializer ser = new SAXSerializer(writer, sw);
        try {
            ser.emit(_citem);
        } catch (XQueryException e) {
            throw new XQRTException("eval failed!: " + e.getMessage());
        }
        return sw.toString();
    }
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

        Writer writer = new NoopWriter();
        SAXWriter saxHandler = new SAXWriter(writer, "UTF-8"); // SAXWriter implements ContentHandler
        saxHandler.setPrettyPrint(true); // enabled formatting
        saxHandler.setXMLDeclaration(true); // insert XML declaration to output
        Serializer ser = new SAXSerializer(saxHandler);
        ser.emit(result); // emit SAX events to SAX handler

        for(Item item : result) {// Note that every Sequence instances implement Iterable.
            // get string value
            String stringValue = item.stringValue();
            // get type
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

            // print string value
            System.out.println(item); // item.toString() invokes item.stringValue()

            // Item is subclass of Sequence, thus it can also be converted to SAX events.
            ser.emit(item);
        }

        // The above 'for each' is equivalent to the following expression.
        IFocus focus = result.iterator(); // IFocus extends Iterable
        while(result.next(focus)) {
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer.emit()

                            XQueryModule mod = proc.parse(query, baseUri);
                            Sequence result = proc.execute(mod);
                            SAXWriter saxwriter = new SAXWriter(res_sw, SAXWriter.DEFAULT_ENCODING);
                            saxwriter.setXMLDeclaration(false);
                            Serializer ser = new SAXSerializer(saxwriter, res_sw);
                            ser.emit(result);
                        } catch (Throwable ex) {
                            final int errors = expectedErrors.getLength();
                            if(errors == 0) {
                                final Node expectedOutputs = (Node) xpath.evaluate("./*[local-name()='output-file'][last()]", testCase, XPathConstants.NODE);
                                assert (expectedOutputs != null);
View Full Code Here

Examples of xbird.xquery.dm.ser.Serializer.emit()

        processor.compile(mod);
        System.err.println(mod.getExpression().toString());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(result);
        String swresult = sw.toString();
        long used = SystemUtils.getHeapUsedMemory();
        stdbuf.append(", used(before GC): " + StringUtils.displayBytesSize(used));
        System.gc();
        used = SystemUtils.getHeapUsedMemory();
View Full Code Here

Examples of xbird.xquery.dm.ser.Serializer.emit()

            throw new XQueryException("failed to execute a query", e);
        }

        SAXWriter saxwr = prepareSAXWriter(writer);
        Serializer ser = new SAXSerializer(saxwr, writer);
        ser.emit(resultSeq);
        if(_wrap) {
            try {
                writer.write("\n</root>\n");
            } catch (IOException e) {
                throw new IllegalStateException(e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.