DEVFYI - Developer Resource - FYI

How Powerful Is Your StAX Parser?

Java Interview Special Tips


(Continued from previous question...)

How Powerful Is Your StAX Parser?

This tip is a simple application that demonstrates
the possibilities of your StAX parser by setting 
the XMLInputFactory properties to true/false. 
The StAX parser tested in this example 
is the BEA and JCP parser.


import javax.xml.stream.*;

public class XMLInputFactoryProperties{
 
    public static void main(String[] args)
        {
String[] properties={"javax.xml.stream.isValidating",
 
    "javax.xml.stream.isNamespaceAware",
 "javax.xml.stream.isCoalescing",
 "javax.xml.stream.isReplacingEntityReferences",
"javax.xml.stream.isSupportingExternalEntities",
"javax.xml.stream.supportDTD"};
        XMLInputFactory XMLif=null;
              
System.setProperty("javax.xml.stream.XMLInputFactory",
"com.bea.xml.stream.MXParserFactory");

        //get an XMLInputFactory instance
        XMLif=XMLInputFactory.newInstance();
                
        //testing
        System.out.println("Case 1:");
        for(int i=0;i

(Continued on next question...)

Other Interview Questions