Listing 2: StAX_EventIterator.java

import javax.xml.stream.*;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stax.*;

public class StAX_EventIterator{
       
   public StAX_EventIterator(){}
 
   public static void main(String[] args)
      {
      XMLInputFactory inputFactory=null;
      XMLEventReader eventReaderXSL=null;
      XMLEventReader eventReaderXML=null;
      Transformer transf=null;
      XMLOutputFactory outputFactory=null;
      XMLEventWriter eventWriter=null;
      Source XSL=null;
      Source XML=null;
              
      //get an instance of the XMLInputFactory class
      inputFactory=XMLInputFactory.newInstance();
        
      //get an instance of the XMLOutputFactory class
      outputFactory=XMLOutputFactory.newInstance();
       
      //set three properties for the XMLInputFactory  
      inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities",Boolean.TRUE);
      inputFactory.setProperty("javax.xml.stream.isNamespaceAware",Boolean.TRUE);
      inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences",Boolean.TRUE);
                                    
      //get the XMLEventReader objects
      try{          
         eventReaderXSL=inputFactory.createXMLEventReader("file:///C://Data_Local//article//",
                        new FileReader("C://Data_local//article//xslFile.xsl"));         
         eventReaderXML=inputFactory.createXMLEventReader("file:///C://Data_Local//article//",
                        new FileReader("C://Data_local//article//xmlFile.xml"));         
         }catch(java.io.FileNotFoundException e)
            {System.out.println(e.getMessage());
         }catch(javax.xml.stream.XMLStreamException e)    
            {System.out.println(e.getMessage());}
                                                                  
      //get a TransformerFactory object
      TransformerFactory transfFactory=TransformerFactory.newInstance();
         
      //define the Source object for the stylesheet
      try{
         XSL=new StAXSource(eventReaderXSL);
         }catch(javax.xml.stream.XMLStreamException e)
            {System.out.println(e.getMessage());}
    
      //get a Transformer object
      try{
         transf=transfFactory.newTransformer(XSL);
         }catch(javax.xml.transform.TransformerConfigurationException e)
            {System.out.println(e.getMessage());}
         
      //define the Source object for the XML document
      try{
         XML=new StAXSource(eventReaderXML);
         }catch(javax.xml.stream.XMLStreamException e)
            {System.out.println(e.getMessage());}
      
      //create an XMLEventWriter object
      try{
         eventWriter=outputFactory.createXMLEventWriter
                     (new FileWriter("C://Data_local//article//members.html"));               
         }catch(java.io.IOException e)
            {System.out.println(e.getMessage());
         }catch(javax.xml.stream.XMLStreamException e)
            {System.out.println(e.getMessage());}
          
      //define the Result object
      Result XML_r=new StAXResult(eventWriter);

      //call the transform method
      try{
         transf.transform(XML,XML_r);
         }catch(javax.xml.transform.TransformerException e)
            {System.out.println(e.getMessage());}
      
      //clean up
      try{
         eventReaderXSL.close(); 
         eventReaderXML.close();          
         eventWriter.close();
         }catch(javax.xml.stream.XMLStreamException e)
            {System.out.println(e.getMessage());}                       
      }
}

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.