Package com.xmlcalabash.io

Examples of com.xmlcalabash.io.ReadablePipe


      return ret;
   }

   protected List<Source> getCalabashResultPort(String name) {
      try {
         ReadablePipe pipe = pipeline.readFrom(name);
         List<Source> nodes = new ArrayList<Source>();

         while(pipe.moreDocuments()) {
            nodes.add(pipe.read().asSource());
         }

         return nodes;
      } catch (SaxonApiException ex) {
         // TODO: Should we log the exception here?
View Full Code Here


    //Serialization serial
   
    //wd = new GenericWritableDocument(runtime, null, serial);
      GenericWritableDocument wd = new GenericWritableDocument(runtime, null, null, output);
    //--where serial is pipeline.getSerialization(port)
      ReadablePipe rpipe = pipeline.readFrom("result");
    //while...
    //try {
      wd.write(rpipe.read());
    //} catch (SaxonApiException e) {
      // TODO Auto-generated catch block
    //  e.printStackTrace();
    } catch (XProcException err) {
                    if (err.getErrorCode() != null) {
View Full Code Here

            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

        pipeline.run();

        portiter = outputports.iterator();
        while (portiter.hasNext()) {
            String port = portiter.next();
            ReadablePipe rpipe = pipeline.readFrom(port);
            rpipe.canReadSequence(true);

            while (rpipe.moreDocuments()) {
                XdmNode doc = rpipe.read();

                TreeWriter tree = new TreeWriter(runtime);
                tree.startDocument(doc.getBaseURI());

                if (detailed) {
View Full Code Here

        }
        return ports;
    }

    public ReadablePipe readFrom(String port) {
        ReadablePipe rpipe = null;
        XOutput output = getOutput(port);
        rpipe = output.getReader();
        rpipe.canReadSequence(true); // FIXME: I should be able to set this correctly!
        return rpipe;
    }
View Full Code Here

                        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();
                }
View Full Code Here

        String testExpr = ((When) step).getTest();
        XdmNode doc = null;
        NamespaceBinding nsbinding = new NamespaceBinding(runtime, step.getNode());
        Hashtable<QName,RuntimeValue> globals = parent.getInScopeOptions();

        ReadablePipe reader = inputs.get("#xpath-context").firstElement();
        doc = reader.read();

        if (reader.moreDocuments() || inputs.get("#xpath-context").size() > 1) {
            throw XProcException.dynamicError(5);
        }

        // Surround testExpr with "boolean()" to force the EBV.
        Vector<XdmItem> results = evaluateXPath(doc, nsbinding.getNamespaceBindings(), "boolean(" + testExpr + ")", globals);
View Full Code Here

    public ReadablePipe getReader() {
        if (documents == null) {
            documents = new DocumentSequence(runtime);
        }
        ReadablePipe pipe = new Pipe(runtime, documents);
        pipe.canReadSequence(sequenceOk);
        readers.add(pipe);
        return pipe;
    }
View Full Code Here

                if (isXml(entity.getMediaType())) {
                    doc = runtime.parse(new InputSource(entity.getStream()));
                    logger.debug("Posting XML document to " + pipeconfig.definput + " for " + id);
                } else {
                    ReadablePipe pipe = null;
                    pipe = new ReadableData(runtime, XProcConstants.c_data, entity.getStream(), entity.getMediaType().toString());
                    doc = pipe.read();
                    logger.debug("Posting non-XML document to " + pipeconfig.definput + " for " + id);
                }

                xpipeline.writeTo(pipeconfig.definput, doc);
View Full Code Here

        QName qname = qnameFromForm(name, getQuery());

        Vector<XdmItem> nodes = new Vector<XdmItem>();

        try {
            ReadablePipe pipe = null;

            if (isXml(entity.getMediaType())) {
                XdmNode doc = runtime.parse(new InputSource(entity.getStream()));
                pipe = new ReadableDocument(runtime, doc, null, null, null);
            } else {
                pipe = new ReadableData(runtime, XProcConstants.c_data, entity.getStream(), entity.getMediaType().toString());
            }

            while (pipe.moreDocuments()) {
                XdmNode doc = pipe.read();
                nodes.add(doc);
            }
        } catch (Exception e) {
            throw new XProcException(e);
        }
View Full Code Here

TOP

Related Classes of com.xmlcalabash.io.ReadablePipe

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.