java.lang.Object
javax.xml.parsers.SAXParserFactory
- See Also:
- Top Examples, Source Code
public abstract boolean getFeature(String name)
throws ParserConfigurationException,
SAXNotRecognizedException,
SAXNotSupportedException
- See Also:
XMLReader.getProperty(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Schema getSchema()
- See Also:
- UnsupportedOperationException,
SAXParserFactory
, setSchema(Schema)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isNamespaceAware()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isValidating()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isXIncludeAware()
- See Also:
- UnsupportedOperationException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static SAXParserFactory newInstance()
- See Also:
- FactoryConfigurationError,
DocumentBuilder
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract SAXParser newSAXParser()
throws ParserConfigurationException,
SAXException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[488]Simple parse
By Erin on 2003/11/04 08:32:13 Rate
package simpleparse;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import org.xml.sax.helpers.DefaultHandler;
public class SimpleParse
{
private static void main ( String argv [ ] )
{
SAXParserFactory factory = SAXParserFactory.newInstance ( ) ;
try
{
SAXParser saxParser = factory.newSAXParser ( ) ;
saxParser.parse ( "book.xml", new DefaultHandler ( ) ) ;
}
catch ( Throwable t )
{
t.printStackTrace ( ) ;
}
System.exit ( 0 ) ;
}
}
protected SAXParserFactory()
- See Also:
newInstance()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public abstract void setFeature(String name,
boolean value)
throws ParserConfigurationException,
SAXNotRecognizedException,
SAXNotSupportedException
- See Also:
- NullPointerException,
SAXParser
, ErrorHandler.fatalError(SAXParseException exception)
, XMLConstants.FEATURE_SECURE_PROCESSING
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1575]Builds a SAX parser and queries it for supported features
By Anonymous on 2005/11/04 20:23:08 Rate
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.*;
public class ParserTest
{
public static void main ( String [ ] args )
{
final String [ ] SAXFeatures =
{
"validation",
"external-general-entities",
"external-parameter-entities",
"namespaces",
"namespace-prefixes",
"string-interning"
} ;
try
{
SAXParserFactory factory = SAXParserFactory.newInstance ( ) ;
System.out.println ( "SAX parser factory class: " +
factory.getClass ( ) .getName ( ) ) ;
System.out.println ( ) ;
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 + "." ) ;
if ( !hasFeature ) try
{
factory.setFeature
( "http://xml.org/sax/features/" + SAXFeatures [ s ] ,
true ) ;
System.out.print ( " ( Can enable. ) " ) ;
}
catch ( SAXException ex )
{
}
}
catch ( SAXNotRecognizedException ex )
{
System.out.print ( "not recognized." ) ;
}
System.out.println ( ) ;
}
System.out.println ( ) ;
}
catch ( Exception ex )
{
ex.printStackTrace ( ) ;
}
}
}
[1578]Demonstration of the effects of the namespace features for a SAX application
By Anonymous on 2005/11/04 20:23:08 Rate
import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
public class NamespaceTest
extends DefaultHandler
{
public static void main ( String [ ] args )
{
try
{
SAXParserFactory factory = SAXParserFactory.newInstance ( ) ;
try
{
factory.setFeature
( "http://xml.org/sax/features/namespaces", true ) ;
factory.setFeature
( "http://xml.org/sax/features/namespace-prefixes", true ) ;
}
catch ( SAXException ex )
{
ex.printStackTrace ( ) ;
}
SAXParser parser = factory.newSAXParser ( ) ;
if ( args.length != 0 )
parser.parse ( new File ( args [ 0 ] ) , new NamespaceTest ( ) ) ;
}
catch ( Exception ex )
{
ex.printStackTrace ( ) ;
}
}
public void startElement
( String URI, String name, String qName, Attributes attributes )
throws SAXException
{
System.out.println ( " { " + URI + " } " + name + " ( " + qName + " ) " ) ;
}
}
public void setNamespaceAware(boolean awareness)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setSchema(Schema schema)
- See Also:
- UnsupportedOperationException,
SAXParser
, SAXException
, isValidating()
, ErrorHandler
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setValidating(boolean validating)
- See Also:
setSchema(Schema)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setXIncludeAware(boolean state)
- See Also:
- UnsupportedOperationException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples