Code example for StreamSource

Methods: getInputStream, getPublicId, getReader, getSystemId

0
 
    public void validate(Source source, Result result) 
        throws SAXException, IOException { 
        if (result == null) {
            final StreamSource streamSource = (StreamSource) source;
            XMLInputSource input = new XMLInputSource(streamSource.getPublicId(), streamSource.getSystemId(), null);
            input.setByteStream(streamSource.getInputStream());
            input.setCharacterStream(streamSource.getReader());
             
            // Gets the parser configuration. We'll create and initialize a new one, if we  
            // haven't created one before or if the previous one was garbage collected. 
            XMLParserConfiguration config = (XMLParserConfiguration) fConfiguration.get();
            if (config == null) {
                config = initialize();
            } 
            // If settings have changed on the component manager, refresh the error handler and entity resolver. 
            else if (fComponentManager.getFeature(PARSER_SETTINGS)) {
                config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER));
                config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER));
            }