tmiller 01/06/12 12:39:00
Modified: java/src/org/apache/xalan/xsltc/runtime
TransformerFactoryImpl.java
Log:
added support for java.io.InputStream StreamSources
Revision Changes Path
1.7 +27 -15
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TransformerFactoryImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TransformerFactoryImpl.java 2001/06/05 18:24:08 1.6
+++ TransformerFactoryImpl.java 2001/06/12 19:38:59 1.7
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TransformerFactoryImpl.java,v 1.6 2001/06/05 18:24:08 tmiller
Exp $
+ * @(#)$Id: TransformerFactoryImpl.java,v 1.7 2001/06/12 19:38:59 tmiller
Exp $
*
* The Apache Software License, Version 1.1
*
@@ -82,6 +82,7 @@
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
import java.io.File;
+import java.io.InputStream;
import java.net.URL;
import java.net.MalformedURLException;
@@ -230,20 +231,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();
- // GTM isSuccessful = xsltc.compile(url);
- isSuccessful = xsltc.compile(url, _errorListener); // GTM
- } 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]