Package de.danet.an.workflow.util

Examples of de.danet.an.workflow.util.SAXEventBufferImpl


     * @throws TransformerConfigurationException
     * @throws TransformerException
     */
    private SAXEventBufferImpl convertToSAXEventBuffer(Source source)
  throws TransformerConfigurationException, TransformerException {
  SAXEventBufferImpl b = new SAXEventBufferImpl();
  SAXResult result = new SAXResult(b);
  TransformerFactory.newInstance().newTransformer()
      .transform(source, result);
  return b;
    }
View Full Code Here


        transformParameters.put(key, value);
    }
      }
  }

  SAXEventBufferImpl seb = new SAXEventBufferImpl ();
  try {
      SAXResult saxResult = new SAXResult (new BodyCleaner(seb));
      Templates tmplts = templates ();
      TransformerHandler th = null;
      if (tmplts == null) {
    th = saxTransFact().newTransformerHandler();
      } else {
    th = saxTransFact().newTransformerHandler(tmplts);
      }
      setTransformerParameters(th.getTransformer(), transformParameters);
      th.setResult(saxResult);
      if (newRootTag == null) {
    // simple input tree
    ((SAXEventBuffer)contentParameters.get(0)).emit(th);
      } else {
    // create new start element
    th.startDocument();
    th.startElement
        ("", newRootTag, newRootTag, new AttributesImpl());
    // content
    Iterator it = contentParameters.iterator();
    while (it.hasNext()) {
        SAXEventBuffer c = (SAXEventBuffer)it.next();
        c.emit(new BodyFilter(th));
    }
    th.endElement("", newRootTag, newRootTag);
    th.endDocument();
      }
      seb.pack();
  } catch (TransformerConfigurationException e) {
      String msg = "Error creating TransformerHandler: " + e.getMessage();
      logger.error(msg, e);
      throw new CannotExecuteException (msg);
  } catch (SAXException se) {
      String msg = "Error during transformation: " + se.getMessage();
      logger.error (msg, se);
      throw new CannotExecuteException (msg);
  }
  if (logger.isDebugEnabled()) {
      logTransformationResult (seb);
  }
 
  // assemble the result, do additional mapping
        Map resData = new HashMap ();
  Document jdomRes = null;
  for (int i = 0; i < formPars.length; i++) {
      if (logger.isDebugEnabled()) {
    logger.debug("formPars[i].id() = " + formPars[i].id());
    logger.debug("formPars[i].type() = " + formPars[i].type());
    logger.debug("formPars[i].mode() = " + formPars[i].mode());
      }
      if (formPars[i].mode() == FormalParameter.Mode.IN) {
    continue;
      }
      XPath path = (XPath)returnParamInfo.get(formPars[i].id());
      if (logger.isDebugEnabled()) {
    logger.debug("path = " + path);
      }
      if (path == null) {
    resData.put(formPars[i].id(), seb);
    continue;
      }
      // Handle path expression
      if (jdomRes == null) {
    try {
        SAXHandler hdlr = new SAXHandler ();
        seb.emit (hdlr);
        jdomRes = hdlr.getDocument();
    } catch (SAXException e) {
        String msg = "Problem converting SAX to JDOM: "
      + e.getMessage ();
        logger.error (msg, e);
View Full Code Here

      Document doc = df.newDocumentBuilder ().newDocument ();
      DocumentFragment frag = doc.createDocumentFragment ();
      frag.appendChild(doc.createElement ("root"));
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer t = tf.newTransformer ();
            SAXEventBufferImpl b = new SAXEventBufferImpl ();
            t.transform (new DOMSource (frag), new SAXResult(b));
            b.pack();
      Map pd = new HashMap ();
      pd.put ("message", b);
      chan.sendMessage(pd);
      Thread.sleep (500);
      process.start();
View Full Code Here

        script.emit (new NamespaceAttributesFilter(jellyParser));
        jscript = jellyParser.getScript ();
        jscript.compile ();
    }
      }
      SAXEventBufferImpl jres = new SAXEventBufferImpl ();
      jres.startDocument ();
      jscript.run (context, new XMLOutput(jres));
      jres.endDocument ();
      jres.pack ();
      Map resData = new HashMap ();
      int argStart = 0;
      if (fps[0].mode() == FormalParameter.Mode.OUT
    && XPDLUtil.isXMLType (fps[0].type())
    && !context.isArg0Set ()) {
View Full Code Here

      res.put (resultPN, null);
      return;
  }

  Parser parser = new Parser ();
  SAXEventBufferImpl sb = new SAXEventBufferImpl ();
  parser.setContentHandler(sb);
  try {
      parser.parse(new InputSource (in));
  } catch (IOException e) {
      throw new CannotExecuteException
    ("Cannot parse response body: " + e.getMessage ());
  } catch (SAXException e) {
      throw new CannotExecuteException
    ("Cannot parse response body: " + e.getMessage ());
  }
  sb.pack ();
  res.put (resultPN, sb);
    }
View Full Code Here

    private SAXEventBuffer convertToSax (Node value)
        throws TransformerException {
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer t = tf.newTransformer();
        SAXEventBufferImpl res = new SAXEventBufferImpl ();
        t.transform (new DOMSource(value), new SAXResult (res));
        return res;
    }
View Full Code Here

      // get processdata
      ProcessData data = process.processContext();
      Object value = data.get("result");
      if (value != null) {
    SAXEventBufferImpl myBuffer
        = (SAXEventBufferImpl)value;
    TransformerFactory tf
        = TransformerFactory.newInstance();
    SAXTransformerFactory saxTransFact = null;
    if (tf.getFeature(SAXTransformerFactory.FEATURE)) {
        saxTransFact = (SAXTransformerFactory)tf;
    }
    TransformerHandler transHand = null;
      transHand = saxTransFact.newTransformerHandler();
      StreamResult streamResult = new StreamResult
          (new java.io.ByteArrayOutputStream());
      transHand.setResult(streamResult);
      myBuffer.emit(transHand);
     System.out.println(streamResult.getOutputStream().toString());

    DOMResult domResult = new DOMResult();
    transHand = saxTransFact.newTransformerHandler();
    transHand.setResult(domResult);
    myBuffer.emit(transHand);
    Element returnResult = ((Document)domResult.getNode())
        .getDocumentElement();

    XPath xpath = new DOMXPath("/BLUB/root/element1");
    Element element1
View Full Code Here

        fps[3] = new FormalParameter("Value", "3", FormalParameter.Mode.IN,
                FP_TYPE_SCHEMA_SAX);
        fps[4] = new FormalParameter("Result", "4", FormalParameter.Mode.OUT,
                FP_TYPE_INT);
       
        SAXEventBufferImpl sax = new SAXEventBufferImpl();
        sax.startDocument();
        AttributesImpl attrs = new AttributesImpl();
        sax.startElement("", "test", "test", attrs);
        sax.endElement("", "test", "test");
        sax.endDocument();
       
        Map act = new java.util.HashMap();
        act.put(fps[0].id(), "java:ejb/WfMOpenTestEJB");
        act.put(fps[1].id(), TestHome.class.getName());
        act.put(fps[2].id(), "toString");
View Full Code Here

        }
        if (value instanceof Wrapper) {
            return ((Wrapper)value).unwrap ();
        }
        if (value instanceof XMLObject) {
            SAXEventBufferImpl seb = new SAXEventBufferImpl();
            if (((XMLObject)value).getClassName().equals("XMLList")) {
                seb.startDocument();
                for (int i = 0; true; i++) {
                    Object item = ((XMLObject)value).get(i, (XMLObject)value);
                    if (item.equals(Scriptable.NOT_FOUND)) {
                        break;
                    }
                    xmlObjectToSax(seb, (XMLObject)item, true);
                }
                seb.endDocument();
            } else {
                xmlObjectToSax(seb, (XMLObject)value, false);
            }
            seb.pack();
            return seb;
        }
        if ((value instanceof Scriptable)
                && ((Scriptable)value).getClassName().equals ("Date")) {
            Scriptable s = (Scriptable)value;
View Full Code Here

            }
            if (fp == null || fp.mode().equals(FormalParameter.Mode.IN)) {
                continue;
            }
            if (XPDLUtil.isXMLType(fp.type())) {
                SAXEventBufferImpl saxVal = new SAXEventBufferImpl();
                try {
                    Transformer t
                        = SAXTransformerFactory.newInstance().newTransformer();
                    t.transform(new DOMSource(param),
                                new SAXResult(new ChildrenOnlyFiler(saxVal)));
View Full Code Here

TOP

Related Classes of de.danet.an.workflow.util.SAXEventBufferImpl

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.