Code example for DefaultHandler

0
String s =
                IOUtils.toString( MockSAXXDocPreprocessor.class.getResourceAsStream( "styles_with_special_encoding.xml" ) );
            StringReader reader = new StringReader( s );
            XMLReader xmlReader = XMLReaderFactory.createXMLReader();
            xmlReader.setContentHandler( new DefaultHandler() );
            xmlReader.parse( new InputSource( reader ) );
            assertTrue( "The 'styles_with_special_encoding.xml' has special encoding, use Reader should crash SAX.",
                        false ); 
        } 
        catch ( Throwable e )
        { 
            // [Fatal Error] :1:1: Content is not allowed in prolog. 
            assertTrue( "The 'styles_with_special_encoding.xml' has special encoding, use Reader crash SAX.", true );
        } 
 
        MockSAXXDocPreprocessor preprocessor = new MockSAXXDocPreprocessor();
        InputStream stream = MockSAXXDocPreprocessor.class.getResourceAsStream( "styles_with_special_encoding.xml" );
        StringWriter writer = new StringWriter();
        preprocessor.preprocess( "test", stream, writer, null, null, null );