java.lang.Object
java.lang.Throwable
java.lang.Exception
org.xml.sax.SAXException
org.xml.sax.SAXNotRecognizedException
- All Implemented Interfaces:
- Serializable
- See Also:
- Top Examples, Source Code,
SAXNotSupportedException
public SAXNotRecognizedException()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1574]How to use SAX parser features
By Anonymous on 2005/11/04 20:23:08 Rate
//How to use SAX parser features
public class ParserTest
{
public static void main ( String [ ] args )
{
//Defining an array of names of known SAX fetures and properties
final String [ ] SAXFeatures =
{
"validation",
"external-general-entities",
"external-parameter-entities",
"namespaces",
"namespace-prefixes",
"string-interning"
} ;
try
{
//Create a new instance of a SAX parser
SAXParserFactory factory = SAXParserFactory.newInstance ( ) ;
System.out.println ( "SAX parser factory class: " +
factory.getClass ( ) .getName ( ) ) ;
System.out.println ( ) ;
//Asks the parser what features it supports, by looping through
//the prepared array and calling getFeature on the factory for
//each request. This method can return true or false or can throw
//the SAXNotREcognizedException to say that it doesn't even know
//about the requested feture
System.out.println ( "SAX Features:" ) ;
for ( int s = 0; s < SAXFeatures.length; ++s )
{
System.out.print ( " " + SAXFeatures [ s ] + ": " ) ;
try
{
boolean hasFeature = factory.getFeature
( "http://xml.org/sax/features/" + SAXFeatures [ s ] ) ;
System.out.print ( "" + hasFeature + "." ) ;
}
catch ( SAXNotRecognizedException ex )
{
System.out.print ( "not recognized." ) ;
}
System.out.println ( ) ;
}
System.out.println ( ) ;
}
catch ( Exception ex )
{
ex.printStackTrace ( ) ;
}
}
}
public SAXNotRecognizedException(String message)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples