Package com.xmlcalabash.io

Examples of com.xmlcalabash.io.WritableDocument


         return new OutputRepresentation(MediaType.APPLICATION_XML) {
            public void write(OutputStream out) {
               try {
                  xproc.getPipeline().run();
                  Serialization serial = xproc.getPipeline().getSerialization(outputPort);              
                  WritableDocument doc = new WritableDocument(cache.getRuntime(),null,serial,out);
                  ReadablePipe rpipe = xproc.getPipeline().readFrom(outputPort);
                  while (rpipe.moreDocuments()) {
                     doc.write(rpipe.read());
                  }
                  out.flush();
               } catch (Exception ex) {
                  getLogger().log(Level.SEVERE,"Exception while running pipeline.",ex);
               }
View Full Code Here


                    if ("version".equals(name)) serial.setVersion(value);
                }
            }

            // I wonder if there's a better way...
            WritableDocument wd = null;
            if (output == null) {
                wd = new WritableDocument(runtime, null, serial);
            } else {
                switch (output.getKind()) {
                    case URI:
                        URI furi = new URI(output.getUri());
                        String filename = furi.getPath();
                        FileOutputStream outfile = new FileOutputStream(filename);
                        wd = new WritableDocument(runtime, filename, serial, outfile);
                        break;

                    case OUTPUT_STREAM:
                        OutputStream outputStream = output.getOutputStream();
                        wd = new WritableDocument(runtime, null, serial, outputStream);
                        break;

                    default:
                        throw new UnsupportedOperationException(format("Unsupported output kind '%s'", output.getKind()));
                }
            }

            try {
                ReadablePipe rpipe = pipeline.readFrom(port);
                while (rpipe.moreDocuments()) {
                    wd.write(rpipe.read());
                }
            } finally {
                if (output != null) {
                    wd.close();
                }
            }
        }

        return portOutputs.containsValue(null);
View Full Code Here

        XdmNode doc = nodes.firstElement();
        nodes.remove(0);

        // I wonder if there's a better way...
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        WritableDocument wd = new WritableDocument(runtime, doc.getBaseURI().toASCIIString(), serial, bos);
        wd.write(doc);

        try {
            String xml = bos.toString("UTF-8");
            Representation result = new StringRepresentation(xml, MediaType.APPLICATION_XML);
            setStatus(Status.SUCCESS_OK);
View Full Code Here

TOP

Related Classes of com.xmlcalabash.io.WritableDocument

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.