Package org.jdom.input

Examples of org.jdom.input.SAXHandler


    ("actParamTests", "jelly-test1", cont);
      process.start();
      assertTrue (stateReached (process, "closed.completed"));
      SAXEventBuffer res = (SAXEventBuffer)
    process.processContext().get ("result");
      SAXHandler sh = new SAXHandler ();
      res.emit (sh);
      Document resDoc = sh.getDocument();
      XPath xpath = new JDOMXPath("/result/inserted/root/element1/@attr1");
      String val = xpath.stringValueOf(resDoc);
      assertTrue ("Value is: " + val, val.equals ("42"));
      xpath = new JDOMXPath("/result/test");
      val = xpath.stringValueOf(resDoc);
View Full Code Here


    ("jelly-test", "jelly-test1", cont);
      process.start();
      assertTrue (stateReached (process, "closed.completed"));
      SAXEventBuffer res = (SAXEventBuffer)
    process.processContext().get ("result");
      SAXHandler sh = new SAXHandler ();
      res.emit (sh);
      Document resDoc = sh.getDocument();
      XPath xpath = new JDOMXPath("/result/inserted/root/element1/@attr1");
      String val = xpath.stringValueOf(resDoc);
      assertTrue ("Value is: " + val, val.equals ("42"));
      xpath = new JDOMXPath("/result/test");
      val = xpath.stringValueOf(resDoc);
View Full Code Here

     *
     * @return the process definition presented as JDOM document.
     */
    public Document toJDOM () {
  try {
      SAXHandler sh = new SAXHandler ();
      procDef.emit(sh, sh);
      return sh.getDocument();
  } catch (SAXException e) {
      logger.error (e.getMessage(), e);
      throw new IllegalStateException
    ("Error generating XPDL as JDOM: " + e.getMessage());
  }
View Full Code Here

      // if value is XML, try converting to JDOM
      try {
          Class[] argTypes = { Element.class };
          method = appClass.getMethod
        ("set" + param, argTypes);
          SAXHandler sh = new SAXHandler ();
          ((SAXEventBufferImpl)value).emit(sh, sh);
          args[0] = sh.getDocument().getRootElement();
      } catch (NoSuchMethodException eee) {
          // finally try converting to W3C DOM
          Class[] argTypes
        = { org.w3c.dom.Element.class };
          method = appClass.getMethod
View Full Code Here

      for (Iterator i = params.keySet().iterator(); i.hasNext();) {
    String pn = (String)i.next();
    Object v = params.get (pn);
    if (v instanceof SAXEventBuffer) {
        try {
      SAXHandler sh = new SAXHandler ();
      convertWithTempRoot(sh, (SAXEventBuffer)v);
      Element temporaryRoot
          = sh.getDocument().getRootElement();
      params.put (pn, temporaryRoot.getChildren());
        } catch (SAXException e) {
      logger.error (e.getMessage(), e);
      throw new ToolInvocationException (e.getMessage());
        }
View Full Code Here

  for (Iterator it = map.keySet().iterator(); it.hasNext();) {
      String name = (String) it.next();
      if (name.equals("complexResult")) {
    SAXEventBufferImpl myBuffer
        = (SAXEventBufferImpl)map.get(name);
    SAXHandler sh = new SAXHandler ();
    sh.startDocument();
    sh.startElement
        ("", "temporary-root", "temporary-root", new AttributesImpl());
    myBuffer.emit(sh, (LexicalHandler)sh);
    sh.endElement ("", "temporary-root", "temporary-root");
    sh.endDocument();
    org.jdom.Element temporaryRoot = sh.getDocument().getRootElement();
    XPath xpath = new JDOMXPath("/temporary-root/row[2]");
    org.jdom.Element painter
        = (org.jdom.Element)xpath.selectSingleNode(temporaryRoot);
    String value = painter.getAttribute("title").getValue();
    // check testXSLT.xml for the expected result
View Full Code Here

  private void parseAndValidate(InputStream inputStream) throws IOException,
      SAXException, SAXNotRecognizedException, SAXNotSupportedException {
    assertNotNull(inputStream);
    UNEdifactInterchangeParser parser = new UNEdifactInterchangeParser();
    parser.setFeature(EDIParser.FEATURE_IGNORE_NEWLINES, true);
    SAXHandler handler = new SAXHandler();
    parser.setContentHandler(handler);
    parser.parse(new InputSource(inputStream));
    Document doc = handler.getDocument();
    // Here you have your document
    StringWriter xmlWriter = new StringWriter();
    new XMLOutputter(Format.getPrettyFormat()).output(doc, xmlWriter);
    String xml = xmlWriter.getBuffer().toString();
    XMLReader reader = EDIParsingUtils.createValidatingReader();
View Full Code Here

TOP

Related Classes of org.jdom.input.SAXHandler

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.