Package org.xml.sax.ext

Examples of org.xml.sax.ext.DefaultHandler2


    }

    @Test
    public void testDoWithSaxResult() throws Exception {
        ContentHandler contentHandler = new DefaultHandler();
        LexicalHandler lexicalHandler = new DefaultHandler2();

        TraxUtils.ResultCallback mock = createMock(TraxUtils.ResultCallback.class);
        mock.saxResult(contentHandler, lexicalHandler);

        replay(mock);
View Full Code Here


        dbf.setNamespaceAware(true);
        dbf.setIgnoringElementContentWhitespace(true);
       
        Document doc = null;
        DocumentBuilder builder = dbf.newDocumentBuilder();
        builder.setErrorHandler(new DefaultHandler2());
       
        boolean foundToURL = false;
        Element docRoot = null;
        try
        {
View Full Code Here

        dbf.setNamespaceAware(true);
        dbf.setIgnoringElementContentWhitespace(true);

        Document doc = null;
        DocumentBuilder builder = dbf.newDocumentBuilder();
        builder.setErrorHandler(new DefaultHandler2());
       
        if(remote)
        {
          // DONE: these GLinks are remote GLinks and so caching them locally would help with
          // performance and network traffic and then using an out of band thread to
View Full Code Here

    roundTripFragment(new Text("bar"));
  }

  @Test
  public void testOutputNullContent() throws JDOMException {
    DefaultHandler2 handler = new DefaultHandler2() {
      @Override
      public void startDocument() throws SAXException {
        throw new SAXException("SHould not be reaching this, ever");
      }
    };
View Full Code Here

                parser.setFeature("http://xml.org/sax/features/validation", true);
            } catch (SAXException e) {
                System.err.println("Cannot activate validation.");
            }
            parser.setEntityResolver(FSEntityResolver.instance());
            DefaultHandler2 dh2 = new DefaultHandler2() {
                boolean isEnt;

                // we'll get a callback for each DTD loaded; we're interested in the entity includes
                public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException {
                    super.externalEntityDecl(name, publicId, systemId);
View Full Code Here

                parser.setFeature("http://xml.org/sax/features/validation", true);
            } catch (SAXException e) {
                System.err.println("Cannot activate validation.");
            }
            parser.setEntityResolver(FSEntityResolver.instance());
            DefaultHandler2 dh2 = new DefaultHandler2() {
                boolean isEnt;

                // we'll get a callback for each DTD loaded; we're interested in the entity includes
                public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException {
                    super.externalEntityDecl(name, publicId, systemId);
View Full Code Here

        ExecutionContext execContext = smooks.createExecutionContext();

        TestParser parser = new TestParser(execContext);
        TestXMLReader reader = (TestXMLReader) parser.createXMLReader();

        parser.configureReader(reader, new DefaultHandler2(), execContext, null);
        assertEquals(8, reader.features.size());
        assertTrue(reader.features.get("feature-on-1"));
        assertTrue(reader.features.get("feature-on-2"));
        assertTrue(!reader.features.get("feature-off-1"));
        assertTrue(!reader.features.get("feature-off-2"));
View Full Code Here

          this.dhandler.startElement(node.getNodeName(), attr);
        } // end if
      } // end else if
      else if (node.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
        if (this.chandler instanceof DefaultHandler2) {
          DefaultHandler2 d2 = (DefaultHandler2) this.chandler;
          d2.startEntity(node.getNodeName());
        } // end if

        if (node.getChildNodes().getLength() == 0) {
          String value = node.getNodeValue();

          if (this.chandler != null) {
            this.chandler.characters(value.toCharArray(), 0, value
                .length());
          } // end if

          if (this.dhandler != null) {
            this.dhandler.characters(value.toCharArray(), 0, value
                .length());
          } // end if
        } // end if
      } // end else if
      else if (node.getNodeType() == Node.TEXT_NODE) {
        String value = node.getNodeValue();

        if (this.chandler != null) {
          this.chandler.characters(value.toCharArray(), 0, value
              .length());
        } // end if

        if (this.dhandler != null) {
          this.dhandler.characters(value.toCharArray(), 0, value
              .length());
        } // end if
      } // end else if
      else if (node.getNodeType() == Node.CDATA_SECTION_NODE) {
        String value = node.getNodeValue();

        if (this.chandler != null) {
          this.chandler.characters(value.toCharArray(), 0, value
              .length());
        } // end if

        if (this.dhandler != null) {
          this.dhandler.characters(value.toCharArray(), 0, value
              .length());
        } // end if
      } // end else if
      else if (node.getNodeType() == Node.COMMENT_NODE) {
        if (this.lHandler != null) {
          String value = node.getNodeValue();
          this.lHandler.comment(value.toCharArray(), 0, value
              .length());
        } // end if
      } else if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
        if (this.chandler != null) {
          ProcessingInstruction pi = (ProcessingInstruction) node;
          this.chandler.processingInstruction(pi.getTarget(), pi
              .getData());
        } // end if

        if (this.dhandler != null) {
          ProcessingInstruction pi = (ProcessingInstruction) node;
          this.dhandler.processingInstruction(pi.getTarget(), pi
              .getData());
        } // end if
      } // end else if

      NodeList nl = node.getChildNodes();

      for (int i = 0; i < nl.getLength(); i++) {
        Node child = nl.item(i);
        this.serialize(child);
      } // end for

      if (node.getNodeType() == Node.ELEMENT_NODE) {
        if (this.chandler != null) {
          String nsUri = node.getNamespaceURI();

          if (nsUri == null) {
            nsUri = "";
          }

          this.chandler.endElement(nsUri, node.getLocalName(), node
              .getNodeName());
        } // end if

        if (this.dhandler != null) {
          this.dhandler.endElement(node.getNodeName());
        } // end if
      } // end else if
      else if (node.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
        if (this.chandler instanceof DefaultHandler2) {
          DefaultHandler2 d2 = (DefaultHandler2) this.chandler;
          d2.endEntity(node.getNodeName());
        } // end if
      } // end else if
    } catch (SAXException ignore) {
    }
  } // end serialize()
View Full Code Here

        }
    }

    private void readBySax() throws SAXException, IOException {
        XMLReader reader = XMLReaderFactory.createXMLReader();
        DefaultHandler2 handler = new DefaultHandler2();

        reader.setContentHandler(handler);
        reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
        reader.setFeature("http://xml.org/sax/features/namespaces", true);
        reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
View Full Code Here

TOP

Related Classes of org.xml.sax.ext.DefaultHandler2

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.