Package xbird.xquery.dm.ser

Examples of xbird.xquery.dm.ser.SAXSerializer.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


    }

    public void writeItemToSAX(ContentHandler saxhdlr) throws XQException {
        final SAXSerializer ser = new SAXSerializer(saxhdlr);
        try {
            ser.emit(item_);
        } catch (XQueryException e) {
            final XQException xqe = new XQException(e.getMessage());
            xqe.initCause(e);
            throw xqe;
        }
View Full Code Here

            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

        SAXWriter saxwr = prepareSAXWriter(writer);
        Serializer ser = new SAXSerializer(saxwr, writer);
        Sequence<? extends Item> result = proc.execute(module);
        if(_timing) {
            final StopWatch sw = new StopWatch("print time");
            ser.emit(result);
            if(_timing_in_msec) {
                System.out.println('\n' + sw.elapsed() + " msec");
            } else {
                System.out.println();
                System.out.println(sw);
View Full Code Here

            } else {
                System.out.println();
                System.out.println(sw);
            }
        } else {
            ser.emit(result);
        }
        if(_wrap) {
            try {
                writer.write("\n</root>\n");
            } catch (IOException e) {
View Full Code Here

        }
        // serialize       
        SAXWriter writer = new SAXWriter(out);
        Serializer ser = new SAXSerializer(writer);
        try {
            ser.emit(result);
        } catch (XQueryException e) {
            reportError("Serialization failed: " + queryPath, e, out);
            return;
        }
    }
View Full Code Here

        QueryRequest request = new QueryRequest(query, ReturnType.ASYNC_REMOTE_SEQUENCE);
        Sequence<Item> resultSeq = (Sequence<Item>) engine.execute(request);
        Writer writer = new FastBufferedWriter(new OutputStreamWriter(System.out), 4096);
        SAXWriter saxwr = new SAXWriter(writer, "UTF-8");
        Serializer ser = new SAXSerializer(saxwr, writer);
        ser.emit(resultSeq);
        writer.flush();
    }

    public static void main(String[] args) {
        TestListenerAdapter adapter = new TestListenerAdapter();
View Full Code Here

        final XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(queryFile).toURI());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        final 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));
        if(RUN_ONLY) {
            res_sw.close();
View Full Code Here

    @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

        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

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.