tmiller     01/06/11 07:08:46

  Modified:    java/src/org/apache/xalan/xsltc/runtime
                        TransletTemplates.java
  Log:
  support for java.io.InputStream StreamSources
  
  Revision  Changes    Path
  1.5       +28 -14    
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TransletTemplates.java
  
  Index: TransletTemplates.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TransletTemplates.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TransletTemplates.java    2001/05/16 11:46:08     1.4
  +++ TransletTemplates.java    2001/06/11 14:08:40     1.5
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TransletTemplates.java,v 1.4 2001/05/16 11:46:08 tmiller Exp $
  + * @(#)$Id: TransletTemplates.java,v 1.5 2001/06/11 14:08:40 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -63,6 +63,7 @@
   
   import javax.xml.transform.Templates;
   import javax.xml.transform.Source; 
  +import javax.xml.transform.stream.StreamSource; 
   import javax.xml.transform.Transformer; 
   import javax.xml.transform.TransformerConfigurationException; 
   import javax.xml.transform.sax.SAXTransformerFactory; 
  @@ -73,6 +74,7 @@
   import java.util.Properties;
   
   import java.io.File;
  +import java.io.InputStream;
   import java.net.URL;
   import java.net.MalformedURLException;
   
  @@ -91,19 +93,31 @@
       {
           XSLTC xsltc = new XSLTC();
           xsltc.init();
  -        String stylesheetName = _stylesheet.getSystemId();
  -        int index = stylesheetName.indexOf('.');
  -        String transletName = stylesheetName.substring(0,index);
  -        boolean isSuccessful = true;
  -        try {
  -            File file = new File(stylesheetName);
  -            URL url = file.toURL();
  -            isSuccessful = xsltc.compile(url);
  -        } catch (MalformedURLException e) {
  -            throw new TransformerConfigurationException(
  -                "URL for stylesheet '" + stylesheetName +
  -                "' can not be formed.");
  -        }
  +
  +     // compile stylesheet
  +     boolean isSuccessful = true;
  +     StreamSource strmsrc = (StreamSource)_stylesheet;
  +     InputStream inputStream = strmsrc.getInputStream();
  +     String stylesheetName = _stylesheet.getSystemId();
  +     String transletName = "no_name";
  +     if (inputStream != null) {
  +         isSuccessful = xsltc.compile(inputStream, transletName);
  +     } else if (stylesheetName != null ){
  +         int index = stylesheetName.indexOf('.');
  +         transletName = stylesheetName.substring(0,index);
  +            try {
  +                File file = new File(stylesheetName);
  +                URL url = file.toURL();
  +                isSuccessful = xsltc.compile(url);
  +            } catch (MalformedURLException e) {
  +                throw new TransformerConfigurationException(
  +                    "URL for stylesheet '" + stylesheetName +
  +                    "' can not be formed.");
  +         }
  +        } else {
  +        throw new TransformerConfigurationException(
  +             "Stylesheet must have a system id or be an InputStream."); 
  +     }
   
           if (!isSuccessful) {
               throw new TransformerConfigurationException(
  
  
  

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

Reply via email to