Package org.dom4j.io

Examples of org.dom4j.io.STAXEventReader


    return new XmlDocumentImpl( toDom4jDocument( staxEventReader, origin ), origin );
  }

  private Document toDom4jDocument(XMLEventReader staxEventReader, Origin origin) {
    STAXEventReader dom4jStaxEventReader = new STAXEventReader();
    try {
      // the dom4j converter class is touchy about comments (aka, comments make it implode)
      // so wrap the event stream in a filtering stream to filter out comment events
      staxEventReader = new FilteringXMLEventReader( staxEventReader ) {
        @Override
        protected XMLEvent filterEvent(XMLEvent event, boolean peek) {
          return event.getEventType() == XMLStreamConstants.COMMENT
              ? null
              : event;
        }
      };

      return dom4jStaxEventReader.readDocument( staxEventReader );
    }
    catch (XMLStreamException e) {
      throw new InvalidMappingException( "Unable to read StAX source as dom4j Document for processing", origin, e );
    }
  }
View Full Code Here


    }

    @Override
    public Document convert(InputStream original) {
        try {
            return new STAXEventReader().readDocument(new InputStreamReader(original,
                                                                            Charset.forName("UTF-8")));
        } catch (XMLStreamException e) {
            throw new CannotConvertBetweenTypesException("Cannot convert from InputStream to dom4j Document.", e);
        }
    }
View Full Code Here

    return new XmlDocumentImpl( toDom4jDocument( staxEventReader, origin ), origin );
  }

  private Document toDom4jDocument(XMLEventReader staxEventReader, Origin origin) {
    STAXEventReader dom4jStaxEventReader = new STAXEventReader();
    try {
      // the dom4j converter class is touchy about comments (aka, comments make it implode)
      // so wrap the event stream in a filtering stream to filter out comment events
      staxEventReader = new FilteringXMLEventReader( staxEventReader ) {
        @Override
        protected XMLEvent filterEvent(XMLEvent event, boolean peek) {
          return event.getEventType() == XMLStreamConstants.COMMENT
              ? null
              : event;
        }
      };

      return dom4jStaxEventReader.readDocument( staxEventReader );
    }
    catch (XMLStreamException e) {
      throw new InvalidMappingException( "Unable to read StAX source as dom4j Document for processing", origin, e );
    }
  }
View Full Code Here

TOP

Related Classes of org.dom4j.io.STAXEventReader

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.