java left logo
java middle logo
java right logo
 

Home arrow Java SE Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 3942
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Accessing features of the SAX parser implementation E-mail
User Rating: / 5
PoorBest 

SAX is an interface specification from W3C. Since, it may have different implementations, it defines specific features and properties.

SAX-interface defines access to implementation-specific features. Moreover, some common features are defined and mandatory; and thus should be supported in all SAX parsers. Example below shows how to get features supportes by XML-parser:

import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXNotRecognizedException;

/**
 * This sample shows how to request the features
 * current SAX-parser implementation supports.
 */

public class RequestFeaturesSample {

   /**
    * Application entry point
    @param args command-line arguments
    */
   public static void main(String[] args) {

      try {

  // creates and returns new instance of SAX-implementation:
  SAXParserFactory factory = SAXParserFactory.newInstance();

  // all the features are represented by boolean values,
  // indicating is each feature set (supported) or not:
  String features[] {
        "http://xml.org/sax/features/namespaces",
     "http://xml.org/sax/features/namespace-prefixes",
     "http://xml.org/sax/features/string-interning",
     "http://xml.org/sax/features/validation",
     "http://xml.org/sax/features/external-general-entities",
     "http://xml.org/sax/features/external-parameter-entities",
     "http://xml.org/sax/features/lexical-handler/parameter-entities",
  };

  // request the values of all the features:
  System.out.println("SAX features:");
  
  for (int i = 0; i < features.length; i++) {
    System.out.print("\t- '" + features[i"' is ");
    try {
    
         System.out.println("'" 
            factory.getFeature(features[i]) "'");
            
    catch (SAXNotRecognizedException ex) {
       System.out.println("not supported");
    }
  }

      catch (Exception ex) {
    ex.printStackTrace();
      }
   }
}


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.