Package de.danet.an.util.sax

Examples of de.danet.an.util.sax.SAXContentBuffer


 
    /**
     * Test
     */
    public void saxContentBuf1() throws Exception {
  SAXContentBuffer buf = new SAXContentBuffer ();
  final String ts1 = "Hello world!";
  StringBuffer ts2 = new StringBuffer ();
  for (int i = 0; i < 5000; i++) {
      ts2.append ("0123456789");
  }
  assertTrue (ts2.length() == 50000);

  buf.characters (ts1.toCharArray(), 0, ts1.toCharArray().length);
  buf.characters (ts2.toString().toCharArray(), 0,
      ts2.toString().toCharArray().length);

  final String[] res = new String[2];
  buf.emit (new DefaultHandler () {
    public void characters (char[] ch, int start, int length)
        throws SAXException {
        if (res[0] == null) {
      res[0] = new String (ch, start, length);
        } else {
View Full Code Here


    /**
     * Test
     */
    public void saxContentBuf2() throws Exception {
  SAXContentBuffer buf = new SAXContentBuffer ();
  XMLReader reader = getReader();
  reader.setContentHandler(buf);
  reader.parse
      (new InputSource
       (Sax.class.getResourceAsStream("/util/testXPDL.xml")));
  XMLStreamReader rdr = buf.createXMLStreamReader();
  int event = 0;
  int sees = 0;
  int eees = 0;
  while (rdr.hasNext()) {
      event = rdr.next ();
View Full Code Here

    /**
     * Test
     */
    public void saxContentBuf3() throws Exception {
  SAXContentBuffer buf = new SAXContentBuffer ();
  XMLReader reader = getReader();
  reader.setContentHandler(buf);
  reader.parse
      (new InputSource
       (Sax.class.getResourceAsStream("/util/simpleSample.xml")));
  assertTrue (buf.toString(),
        buf.toString().equals ("<body><item/></body>"));
   }
View Full Code Here

        xr = spf.newSAXParser().getXMLReader();
    } catch (SAXException e) {
        xr = new XmlnsUrisPatcher
      (spf.newSAXParser().getXMLReader());
    }
    SAXContentBuffer seb = new SAXEventBufferImpl ();
    XMLFilterImpl filter = new XMLFilterImpl () {
      private int level = 0;
      public void startElement
          (String uri, String localName, String qName,
           Attributes atts) throws SAXException {
          if (level > 0) {
        super.startElement (uri,localName,qName,atts);
          }
          level += 1;
      }
      public void endElement
          (String uri, String localName, String qName)
          throws SAXException{
          level -= 1;
          if (level > 0) {
        super.endElement (uri, localName, qName);
          }
      }
        };
    filter.setContentHandler (seb);
    xr.setContentHandler (filter);
    xr.parse (new InputSource
        (new StringReader
         ("<temporary-root>" + valueElem.getText()
          + "</temporary-root>")));
    seb.pack();
    return seb;
      } catch (ParserConfigurationException e) {
    throw new IllegalArgumentException
        ("Error initiliazing schema type: " + e.getMessage ());
      } catch (SAXException e) {
View Full Code Here

            WfRequester cont = new DefaultRequester(workflowService());
            Process process = (Process)createProcess
                ("actParamTests", "testE4xActParam", cont);
            process.start();
            assertTrue (stateReached (process, "closed.completed"));
            SAXContentBuffer res = (SAXContentBuffer)
                process.processContext().get ("result");
            Node resRoot = res.toW3cDom();
            Node fc = resRoot.getFirstChild();
            assertTrue (fc.toString(), fc.getLocalName().equals("Hello"));
            Node child = fc.getFirstChild();
            String data = "";
            do {
View Full Code Here

            ProcessMgr pmgr = procDefDir.processMgr ("jstests", "testReplacer");
            WfProcess process
                = pmgr.createProcess(new DefaultRequester (workflowService));
            process.start();
            assertTrue (stateReached (process, "closed.completed"));
            SAXContentBuffer xmlRes = (SAXContentBuffer)
                process.processContext().get("XMLResult");
            Node resRoot = xmlRes.toW3cDom();
            Node fc = resRoot.getFirstChild();
            assertTrue (fc.toString(), fc.getLocalName().equals("Item"));
            assertTrue (fc.getAttributes().getNamedItem("Id")
                        .getNodeValue().equals("Start"));
            assertTrue (process.processContext().get("Result").equals("Test"));
View Full Code Here

TOP

Related Classes of de.danet.an.util.sax.SAXContentBuffer

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.