- Javax.xml.bind classes
- Home
- Binder
- DatatypeConverter
- JAXB
- JAXBContext
- JAXBElement
- JAXBElement.GlobalScope
- JAXBIntrospector
- Marshaller.Listener
- SchemaOutputResolver
- Unmarshaller.Listener
- Javax.xml.bind.util classes
- JAXBResult
- JAXBSource
- ValidationEventCollector
- Javax.xml.parsers classes
- DocumentBuilder
- DocumentBuilderFactory
- SAXParser
- SAXParserFactory
- Javax.xml.soap classes
- AttachmentPart
- MessageFactory
- MimeHeader
- MimeHeaders
- SAAJMetaFactory
- SOAPConnection
- SOAPConnectionFactory
- SOAPFactory
- SOAPMessage
- SOAPPart
- Javax.xml.validation classes
- Schema
- SchemaFactory
- TypeInfoProvider
- Validator
- ValidatorHandler
- Javax.xml.xpath classes
- XPathConstants
- XPathFactory
- Java Useful Resources
- Java - Quick Guide
- Java - Useful Resources
SAXParserFactory setFeature() Method
Description
The Javax.xml.parsers.SAXParserFactory.setFeature(String name, boolean value) method sets the particular feature in the underlying implementation of org.xml.sax.XMLReader. A list of the core features and properties can be found at http://www.saxproject.org/
All implementations are required to support the XMLConstants.FEATURE_SECURE_PROCESSING feature.
Declaration
Following is the declaration for Javax.xml.parsers.SAXParserFactory.setFeature() method
public abstract void setFeature(String name, boolean value)
Parameters
name − The name of the feature to be set.
value − The value of the feature to be set.
Return Value
This method does not return a value.
Exception
ParserConfigurationException − if a parser cannot be created which satisfies the requested configuration.
SAXNotRecognizedException − When the underlying XMLReader does not recognize the property name.
SAXNotSupportedException − When the underlying XMLReader recognizes the property name but doesn't support the property.
NullPointerException − If the name parameter is null.
Example
The following example shows the usage of Javax.xml.parsers.SAXParserFactory.setFeature() method.
package com.tutorialspoint; import javax.xml.parsers.SAXParserFactory; public class SAXParserFactoryDemo { public static void main(String[] args) { // create a new SAXParserFactory SAXParserFactory factory = SAXParserFactory.newInstance(); try { // get the feature status boolean status = factory.getFeature("http://xml.org/sax/features/namespaces"); // print the status System.out.println("" + status); // set the feature of namespaces factory.setFeature("http://xml.org/sax/features/namespaces", true); // get the feature status status = factory.getFeature("http://xml.org/sax/features/namespaces"); // print the status System.out.println("" + status); } catch (Exception ex) { ex.printStackTrace(); } } }
If we compile the code and execute it, this will produce the following result −
false true
To Continue Learning Please Login
Login with Google