/*
 * Fast Infoset ver. 0.1 software ("Software")
 * 
 * Copyright, 2004-2005 Sun Microsystems, Inc. All Rights Reserved. 
 * 
 * Software is licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may
 * obtain a copy of the License at:
 * 
 *        http://www.apache.org/licenses/LICENSE-2.0
 * 
 *    Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations.
 * 
 *    Sun supports and benefits from the global community of open source
 * developers, and thanks the community for its important contributions and
 * open standards-based technology, which Sun has adopted into many of its
 * products.
 * 
 *    Please note that portions of Software may be provided with notices and
 * open source licenses from such communities and third parties that govern the
 * use of those portions, and any licenses granted hereunder do not alter any
 * rights and obligations you may have under such open source licenses,
 * however, the disclaimer of warranty and limitation of liability provisions
 * in this License will apply to all Software in this distribution.
 * 
 *    You acknowledge that the Software is not designed, licensed or intended
 * for use in the design, construction, operation or maintenance of any nuclear
 * facility.
 *
 * Apache License
 * Version 2.0, January 2004
 * http://www.apache.org/licenses/
 *
 */ 


package com.sun.xml.fastinfoset.tools;

import com.sun.xml.fastinfoset.sax.SAXDocumentSerializer;
import java.io.InputStream;
import java.io.OutputStream;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

public class XML_SAX_FI extends TransformInputOutput {
    
    public XML_SAX_FI() {
    }

    public void parse(InputStream xml, OutputStream finf) throws Exception {
        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
        saxParserFactory.setNamespaceAware(true);
        SAXParser saxParser = saxParserFactory.newSAXParser();

        SAXDocumentSerializer documentSerializer = new SAXDocumentSerializer();
        documentSerializer.setOutputStream(finf);

        saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", documentSerializer);
        saxParser.parse(xml, documentSerializer);
    }
    
    public static void main(String[] args) throws Exception {
        XML_SAX_FI s = new XML_SAX_FI();
        s.parse(args);
    }
}

@@ -1876,16 +1876,126 @@
 Factory;
+%0Aimport javax.xml.parsers.ParserConfigurationException;%0Aimport java.io.Reader;%0Aimport org.xml.sax.InputSource;
 %0A%0Apublic
@@ -2175,23 +2175,16 @@
 AXParser
-Factory
  saxPars
@@ -2189,99 +2189,405 @@
 rser
-Factory = SAXParserFactory.newInstance();%0A        saxParserFactory.setNamespaceAware(true);
+ = getParser();%0A        SAXDocumentSerializer documentSerializer = getSerializer(finf);%0A        %0A        saxParser.setProperty(%22http://xml.org/sax/properties/lexical-handler%22, documentSerializer);%0A        saxParser.parse(xml, documentSerializer);%0A    %7D%0A        %0A    public void convert(Reader reader, OutputStream finf) throws Exception %7B%0A        InputSource is = new InputSource(reader);%0A        
 %0A   
@@ -2617,31 +2617,11 @@
 r = 
-saxParserFactory.newSAX
+get
 Pars
@@ -2626,17 +2626,16 @@
 rser();%0A
-%0A
         
@@ -2681,22 +2681,10 @@
 r = 
-new SAXDocumen
+ge
 tSer
@@ -2691,16 +2691,20 @@
 ializer(
+finf
 );%0A     
@@ -2710,50 +2710,8 @@
     
-documentSerializer.setOutputStream(finf);%0A
 %0A   
@@ -2835,44 +2835,598 @@
 rse(
-xml, documentSerializer);%0A    %7D%0A    
+is, documentSerializer);%0A    %7D%0A    %0A    private SAXParser getParser() %7B%0A        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();%0A        saxParserFactory.setNamespaceAware(true);%0A        try %7B%0A            return saxParserFactory.newSAXParser(); %0A        %7D catch (Exception e)%0A        %7B%0A            return null;%0A        %7D%0A    %7D%0A    %0A    private SAXDocumentSerializer getSerializer(OutputStream finf) %7B%0A        SAXDocumentSerializer documentSerializer = new SAXDocumentSerializer();%0A        documentSerializer.setOutputStream(finf);%0A        return documentSerializer;%0A    %7D
 %0A   

add convert() for eventreader, no changes to original function.