[ http://nagoya.apache.org/jira/browse/XALANJ-101?page=history ]

Henry Zongaro updated XALANJ-101:
---------------------------------

      Assign To:     (was: Xalan Developers Mailing List)
           type: Improvement  (was: Bug)
    Description: 
import java.io.FileInputStream;
import javax.xml.transform.Templates;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import org.xml.sax.helpers.AttributesImpl;

public class Test {

        public static void main(String[] args) {
                try {
                        SAXTransformerFactory f = (SAXTransformerFactory)
SAXTransformerFactory.newInstance();
                        Templates t = f.newTemplates(new StreamSource(new 
FileInputStream("in.xsl")));
                        TransformerHandler th = f.newTransformerHandler(t);
                        th.setResult(new StreamResult(System.out));

                        th.startDocument();
                        th.startElement("","foo","foo",new AttributesImpl());
                        th.endElement("","foo","foo");
                        th.endDocument();

                        th.startDocument();
                        th.startElement("","foo","foo",new AttributesImpl());
                        th.endElement("","foo","foo");
                        th.endDocument();
                } catch(Exception e) {
                        e.printStackTrace();
                }
        }
}

If you run this code with any valid in.xsl file, the template is instantiated 
only once.
It's true, that in JAXP-1.1 specification it is not explicitly stated that 
TransformerHandlers should be reusable, but it is stated that Transformers 
should be reusable, and my opinion is that it would be reasonable and natural 
to be able to reuse TransformerHandlers as well.

  was:
import java.io.FileInputStream;
import javax.xml.transform.Templates;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import org.xml.sax.helpers.AttributesImpl;

public class Test {

        public static void main(String[] args) {
                try {
                        SAXTransformerFactory f = (SAXTransformerFactory)
SAXTransformerFactory.newInstance();
                        Templates t = f.newTemplates(new StreamSource(new 
FileInputStream("in.xsl")));
                        TransformerHandler th = f.newTransformerHandler(t);
                        th.setResult(new StreamResult(System.out));

                        th.startDocument();
                        th.startElement("","foo","foo",new AttributesImpl());
                        th.endElement("","foo","foo");
                        th.endDocument();

                        th.startDocument();
                        th.startElement("","foo","foo",new AttributesImpl());
                        th.endElement("","foo","foo");
                        th.endDocument();
                } catch(Exception e) {
                        e.printStackTrace();
                }
        }
}

If you run this code with any valid in.xsl file, the template is instantiated 
only once.
It's true, that in JAXP-1.1 specification it is not explicitly stated that 
TransformerHandlers should be reusable, but it is stated that Transformers 
should be reusable, and my opinion is that it would be reasonable and natural 
to be able to reuse TransformerHandlers as well.

    Environment: 
Operating System: All
Platform: PC

  was:
Operating System: All
Platform: PC

       Priority: Major
    Bugzilla Id:   (was: 1205)

> TransformerHandler not reusable
> -------------------------------
>
>          Key: XALANJ-101
>          URL: http://nagoya.apache.org/jira/browse/XALANJ-101
>      Project: XalanJ2
>         Type: Improvement
>   Components: transformation, Xalan-interpretive
>     Versions: 2.0.1
>  Environment: Operating System: All
> Platform: PC
>     Reporter: slobo

>
> import java.io.FileInputStream;
> import javax.xml.transform.Templates;
> import javax.xml.transform.sax.SAXTransformerFactory;
> import javax.xml.transform.sax.TransformerHandler;
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.transform.stream.StreamResult;
> import org.xml.sax.helpers.AttributesImpl;
> public class Test {
>       public static void main(String[] args) {
>               try {
>                       SAXTransformerFactory f = (SAXTransformerFactory)
> SAXTransformerFactory.newInstance();
>                       Templates t = f.newTemplates(new StreamSource(new 
> FileInputStream("in.xsl")));
>                       TransformerHandler th = f.newTransformerHandler(t);
>                       th.setResult(new StreamResult(System.out));
>                       th.startDocument();
>                       th.startElement("","foo","foo",new AttributesImpl());
>                       th.endElement("","foo","foo");
>                       th.endDocument();
>                       th.startDocument();
>                       th.startElement("","foo","foo",new AttributesImpl());
>                       th.endElement("","foo","foo");
>                       th.endDocument();
>               } catch(Exception e) {
>                       e.printStackTrace();
>               }
>       }
> }
> If you run this code with any valid in.xsl file, the template is instantiated 
> only once.
> It's true, that in JAXP-1.1 specification it is not explicitly stated that 
> TransformerHandlers should be reusable, but it is stated that Transformers 
> should be reusable, and my opinion is that it would be reasonable and natural 
> to be able to reuse TransformerHandlers as well.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to