Serializer serializer = SerializerFactory.getSerializer("xml");
Serializer serializer = SerializerFactory.getSerializer (OutputProperties.getDefaultMethodProperties("xml"));
  public static void main(String[] args)	throws TransformerException, TransformerConfigurationException,          SAXException, IOException	   	{    // Instantiate a TransformerFactory.  	TransformerFactory tFactory = TransformerFactory.newInstance();    // Determine whether the TransformerFactory supports The use of SAXSource     // and SAXResult    if (tFactory.getFeature(SAXSource.FEATURE) && tFactory.getFeature(SAXResult.FEATURE))    {       // Cast the TransformerFactory.      SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);      // Create a ContentHandler to handle parsing of the stylesheet.      TemplatesHandler templatesHandler = saxTFactory.newTemplatesHandler();      // Create an XMLReader and set its ContentHandler.      XMLReader reader = XMLReaderFactory.createXMLReader();      reader.setContentHandler(templatesHandler);          // Parse the stylesheet.                             reader.parse("birds.xsl");      //Get the Templates object from the ContentHandler.      Templates templates = templatesHandler.getTemplates();      // Create a ContentHandler to handle parsing of the XML source.        TransformerHandler handler         = saxTFactory.newTransformerHandler(templates);      // Reset the XMLReader's ContentHandler.      reader.setContentHandler(handler);        // Set the ContentHandler to also function as a LexicalHandler, which      // includes "lexical" events (e.g., comments and CDATA).       reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);         	  FileOutputStream fos = new FileOutputStream("birds.out");      Serializer serializer = SerializerFactory.getSerializer("xml");      serializer.setOutputStream(fos);               // Set the result handling to be a serialization to the file output stream.      Result result = new SAXResult(serializer.asContentHandler());      handler.setResult(result);            // Parse the XML input document.      reader.parse("birds.xml");          	System.out.println("************* The result is in birds.out *************");	    }	    else      System.out.println("The TransformerFactory does not support SAX input and SAX output");  }