orbeon.apache.xerces.impl.XMLEntityManager

Here are the examples of the java api class orbeon.apache.xerces.impl.XMLEntityManager taken from open source projects.

1. XMLParsing#getReaderFromXMLInputStream()

Project: orbeon-forms
File: XMLParsing.java
/**
     * Given an input stream, return a reader. This performs encoding detection as per the XML spec. Caller must close
     * the resulting Reader when done.
     *
     * @param inputStream   InputStream to process
     * @return              Reader initialized with the proper encoding
     * @throws IOException
     */
public static Reader getReaderFromXMLInputStream(InputStream inputStream) throws IOException {
    // Create a Xerces XMLInputSource
    final XMLInputSource inputSource = new XMLInputSource(null, null, null, inputStream, null);
    // Obtain encoding from Xerces
    final XMLEntityManager entityManager = new XMLEntityManager();
    // prevent NPE by providing this
    entityManager.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY, new XMLErrorReporter());
    // the result is the encoding, but we don't use it directly
    entityManager.setupCurrentEntity("[xml]", inputSource, false, true);
    return entityManager.getCurrentEntity().reader;
}