Code example for SAXParser: Parsing XML documents

Methods: parsesetProperty

0
 
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setValidating( true );
        factory.setNamespaceAware( true );
        SAXParser saxParser = factory.newSAXParser();
        saxParser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                               "http://www.w3.org/2001/XMLSchema" ); 
        saxParser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaSource", archetypeXsd );
 
        InputStream in = getClass().getResourceAsStream( "sample-archetype.xml" );
        try 
        { 
            saxParser.parse( new InputSource( in ), new Handler() );
        } 
        finally 
        { 
            IOUtil.close( in );
        } 
    }