Examples of SAXSerializer


Examples of org.exist.util.serializer.SAXSerializer

    {
        if( dest != null ) {
            final Properties outputProperties = new Properties();
            outputProperties.setProperty( OutputKeys.INDENT, "yes" );

            final SAXSerializer serializer = (SAXSerializer)SerializerPool.getInstance().borrowObject( SAXSerializer.class );

            Writer        writer     = null;

            if( dest.isDirectory() ) {

                if( !dest.exists() ) {
                    dest.mkdirs();
                }
                String fname = resource.getId();

                if( !fname.endsWith( ".xml" ) ) {
                    fname += ".xml";
                }
                final File file = new File( dest, fname );
                writer = new OutputStreamWriter( new FileOutputStream( file ), encoding );
            } else {
                writer = new OutputStreamWriter( new FileOutputStream( dest ), encoding );
            }

            serializer.setOutput( writer, outputProperties );
            resource.getContentAsSAX( serializer );
            writer.close();

            SerializerPool.getInstance().returnObject( serializer );
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer

                public void actionPerformed(ActionEvent e) {
                    String selected = (String) cell.getUserObject();
                    XQExpression expr = sourceExprMap.get(selected);
                    DynamicContext dynEnv = new DynamicContext(statEnv);
                    StringWriter sw = new StringWriter();
                    SAXSerializer ser = new SAXSerializer(new SAXWriter(sw), sw);
                    try {
                        expr.evalAsEvents(ser, ValueSequence.EMPTY_SEQUENCE, dynEnv);
                    } catch (Exception ex) {
                        JOptionPane.showMessageDialog(frame, "eval failed!: " + ex.getMessage());
                        ex.printStackTrace();
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer

        if(DEBUG_LIGHT) {
            System.err.println(query);
        }
        XQueryModule mod = processor.parse(query, uri);
        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        processor.execute(mod, ser);
        //Sequence<? extends Item> reseq = processor.execute(mod);
        //ser.emit(reseq);
        String result = res_sw.toString();
        return result;
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer

        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(DOC_BASE).toURI());
        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.SAXSerializer

            throw new XQException("Unsupport Result class: " + result.getClass().getName());
        }
    }

    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

Examples of xbird.xquery.dm.ser.SAXSerializer

        } catch (RemoteException e) {
            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

Examples of xbird.xquery.dm.ser.SAXSerializer

    }

    public void executeWithPushMode(XQueryProcessor proc, XQueryModule module, Writer writer)
            throws XQueryException {
        SAXWriter saxwr = prepareSAXWriter(writer);
        Serializer ser = new SAXSerializer(saxwr, writer);
        proc.execute(module, ser);
        if(_wrap) {
            try {
                writer.write("\n</root>\n");
            } catch (IOException e) {
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer

    }

    public void executeWithPullMode(XQueryProcessor proc, XQueryModule module, Writer writer)
            throws XQueryException {
        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);
            }
        } else {
            ser.emit(result);
        }
        if(_wrap) {
            try {
                writer.write("\n</root>\n");
            } catch (IOException e) {
View Full Code Here

Examples of xbird.xquery.dm.ser.SAXSerializer

            reportError("Execution failed: " + queryPath, e, out);
            return;
        }
        // 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

Examples of xbird.xquery.dm.ser.SAXSerializer

        String query = IOUtils.toString(new FileInputStream(fileName));
        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();
    }
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.