sboag 00/11/17 17:19:15
Modified: java/samples/trax Examples.java
java/src/javax/xml/transform OutputKeys.java
Transformer.java TransformerException.java
TransformerFactory.java
java/src/javax/xml/transform/dom DOMResult.java
DOMSource.java
java/src/javax/xml/transform/sax SAXSource.java
TemplatesHandler.java TransformerHandler.java
java/src/javax/xml/transform/stream StreamResult.java
StreamSource.java
java/src/org/apache/xalan/transformer TransformerImpl.java
Log:
Changes made to TrAX API in response to Sun evaluation:
StreamSource/Result now have File constructors and setSystemID(File).
set/getCharacterStream and set/getByteStream now changed
to set/getReader/Writer and set/getInput/OutputStream.
Added getCause stuff to TransformerException.
Added clearParameters method.
Revision Changes Path
1.6 +27 -0 xml-xalan/java/samples/trax/Examples.java
Index: Examples.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/trax/Examples.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Examples.java 2000/11/16 03:16:46 1.5
+++ Examples.java 2000/11/18 01:19:13 1.6
@@ -60,6 +60,13 @@
handleException(ex);
}
+ System.out.println("\n\n==== exampleSimple2 ====");
+ try {
+ exampleSimple2("xml/foo.xml", "xsl/foo.xsl");
+ } catch( Exception ex ) {
+ handleException(ex);
+ }
+
System.out.println("\n\n==== exampleFromStream ====");
try {
exampleFromStream("xml/foo.xml", "xsl/foo.xsl");
@@ -186,6 +193,26 @@
transformer.transform( new StreamSource(sourceID),
new StreamResult(System.out));
}
+
+ /**
+ * Show the simplest possible transformation from File
+ * to a File.
+ */
+ public static void exampleSimple2(String sourceID, String xslID)
+ throws TransformerException, TransformerConfigurationException
+ {
+ // Create a transform factory instance.
+ TransformerFactory tfactory = TransformerFactory.newInstance();
+
+ // Create a transformer for the stylesheet.
+ Transformer transformer
+ = tfactory.newTransformer(new StreamSource(xslID));
+
+ // Transform the source XML to System.out.
+ transformer.transform( new StreamSource(new File(sourceID)),
+ new StreamResult(new File("foo.out")));
+ }
+
/**
* Show simple transformation from input stream to output stream.
1.4 +6 -0 xml-xalan/java/src/javax/xml/transform/OutputKeys.java
Index: OutputKeys.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/javax/xml/transform/OutputKeys.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OutputKeys.java 2000/11/15 02:59:42 1.3
+++ OutputKeys.java 2000/11/18 01:19:13 1.4
@@ -67,6 +67,12 @@
public class OutputKeys
{
/**
+ * Default constructor is private on purpose. This class is
+ * only for static variable access, and should never be constructed.
+ */
+ private OutputKeys(){}
+
+ /**
* method = "xml" | "html" | "text" | <var>qname-but-not-ncname</var>.
*
* <p>The method attribute identifies the overall method that
1.9 +11 -1 xml-xalan/java/src/javax/xml/transform/Transformer.java
Index: Transformer.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/javax/xml/transform/Transformer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Transformer.java 2000/11/15 22:25:22 1.8
+++ Transformer.java 2000/11/18 01:19:13 1.9
@@ -67,13 +67,18 @@
* then be used to process XML from a variety of sources and write
* the transformation output to a variety of sinks.</p>
*
* <p>An object of this class may not be used in multiple threads
- * running concurrently.</p>
+ * running concurrently. Different Transformers may be used
+ * concurrently by different threads.</p>
*
* <p>A Transformer may be used multiple times. Parameters and
* output properties are preserved across transformations.</p>
*/
public abstract class Transformer
{
+ /**
+ * Default constructor is protected on purpose.
+ */
+ protected Transformer(){}
/**
* Process the source tree to the output result.
@@ -119,6 +124,11 @@
* or setParameters.
*/
public abstract Object getParameter(String name);
+
+ /**
+ * Clear all parameters set with setParameter.
+ */
+ public abstract void clearParameters();
/**
* Set an object that will be used to resolve URIs used in
1.5 +44 -1
xml-xalan/java/src/javax/xml/transform/TransformerException.java
Index: TransformerException.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/TransformerException.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TransformerException.java 2000/11/14 18:56:25 1.4
+++ TransformerException.java 2000/11/18 01:19:13 1.5
@@ -87,13 +87,56 @@
Exception containedException;
/**
- * Method getException retrieves an exception that this exception wraps.
+ * This method retrieves an exception that this exception wraps.
*
* @return An Exception object, or null.
+ * @see #getCause
*/
public Exception getException()
{
return containedException;
+ }
+
+ /**
+ * Returns the cause of this throwable or <code>null</code> if the
+ * cause is nonexistent or unknown. (The cause is the throwable that
+ * caused this throwable to get thrown.)
+ */
+ public Throwable getCause() {
+ return (containedException==this ? null : containedException);
+ }
+
+ /**
+ * Initializes the <i>cause</i> of this throwable to the specified value.
+ * (The cause is the throwable that caused this throwable to get thrown.)
+ *
+ * <p>This method can be called at most once. It is generally called from
+ * within the constructor, or immediately after creating the
+ * throwable. If this throwable was created
+ * with [EMAIL PROTECTED] #TransformerException(Exception)} or
+ * [EMAIL PROTECTED] #TransformerException(String,Exception)}, this method
cannot be called
+ * even once.
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * [EMAIL PROTECTED] #getCause()} method). (A <tt>null</tt> value
is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @return a reference to this <code>Throwable</code> instance.
+ * @throws IllegalArgumentException if <code>cause</code> is this
+ * throwable. (A throwable cannot
+ * be its own cause.)
+ * @throws IllegalStateException if this throwable was
+ * created with [EMAIL PROTECTED]
#TransformerException(Exception)} or
+ * [EMAIL PROTECTED] #TransformerException(String,Exception)}, or
this method has already
+ * been called on this throwable.
+ */
+ public synchronized Throwable initCause(Throwable cause) {
+ if (this.containedException == null)
+ throw new IllegalStateException("Can't overwrite cause");
+ if (containedException == this)
+ throw new IllegalArgumentException("Self-causation not permitted");
+ this.containedException = containedException;
+ return this;
}
/**
1.10 +2 -0
xml-xalan/java/src/javax/xml/transform/TransformerFactory.java
Index: TransformerFactory.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/TransformerFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TransformerFactory.java 2000/11/15 22:25:22 1.9
+++ TransformerFactory.java 2000/11/18 01:19:13 1.10
@@ -148,6 +148,8 @@
/**
* Process the Source into a Transformer object. Care must
* be given not to use this object in multiple threads running
concurrently.
+ * Different TransformerFactories can be used concurrently by different
+ * threads.
*
* @param source An object that holds a URI, input stream, etc.
*
1.6 +20 -7 xml-xalan/java/src/javax/xml/transform/dom/DOMResult.java
Index: DOMResult.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/dom/DOMResult.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DOMResult.java 2000/11/15 02:34:31 1.5
+++ DOMResult.java 2000/11/18 01:19:14 1.6
@@ -82,15 +82,20 @@
= "http://javax.xml.transform.dom.DOMResult/feature";
/**
- * Zero-argument default constructor. If this constructor is used, and
- * no output DOM source is set, then the transformer will
- * create an output [EMAIL PROTECTED] org.w3c.dom.Document} using
- * [EMAIL PROTECTED] javax.xml.parsers.DocumentBuilder#newDocument}.
+ * Zero-argument default constructor. In practice,
+ * the node should be a [EMAIL PROTECTED] org.w3c.dom.Document} node,
+ * a [EMAIL PROTECTED] org.w3c.dom.DocumentFragment} node, or a
+ * [EMAIL PROTECTED] org.w3c.dom.Element} node. In other words, a node
+ * that accepts children.
*/
public DOMResult(){}
/**
- * Use a DOM node to create a new output target.
+ * Use a DOM node to create a new output target. In practice,
+ * the node should be a [EMAIL PROTECTED] org.w3c.dom.Document} node,
+ * a [EMAIL PROTECTED] org.w3c.dom.DocumentFragment} node, or a
+ * [EMAIL PROTECTED] org.w3c.dom.Element} node. In other words, a node
+ * that accepts children.
*
* @param n The DOM node that will contain the result tree.
*/
@@ -100,7 +105,11 @@
}
/**
- * Create a new output target with a DOM node.
+ * Create a new output target with a DOM node. In practice,
+ * the node should be a [EMAIL PROTECTED] org.w3c.dom.Document} node,
+ * a [EMAIL PROTECTED] org.w3c.dom.DocumentFragment} node, or a
+ * [EMAIL PROTECTED] org.w3c.dom.Element} node. In other words, a node
+ * that accepts children.
*
* @param node The DOM node that will contain the result tree.
* @param systemID The system identifier which may be used in association
@@ -113,7 +122,11 @@
}
/**
- * Set the node that will contain the result DOM tree.
+ * Set the node that will contain the result DOM tree. In practice,
+ * the node should be a [EMAIL PROTECTED] org.w3c.dom.Document} node,
+ * a [EMAIL PROTECTED] org.w3c.dom.DocumentFragment} node, or a
+ * [EMAIL PROTECTED] org.w3c.dom.Element} node. In other words, a node
+ * that accepts children.
*
* @param node The node to which the transformation
* will be appended.
1.7 +5 -1 xml-xalan/java/src/javax/xml/transform/dom/DOMSource.java
Index: DOMSource.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/dom/DOMSource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DOMSource.java 2000/11/16 16:22:08 1.6
+++ DOMSource.java 2000/11/18 01:19:14 1.7
@@ -89,7 +89,11 @@
public DOMSource(){}
/**
- * Create a new input source with a DOM node.
+ * Create a new input source with a DOM node. The operation
+ * will be applied to the subtree rooted at this node. In XSLT,
+ * a "/" pattern still means the root of the tree (not the subtree),
+ * and the evaluation of global variables and parameters is done
+ * from the root node also.
*
* @param n The DOM node that will contain the Source tree.
*/
1.7 +5 -3 xml-xalan/java/src/javax/xml/transform/sax/SAXSource.java
Index: SAXSource.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/sax/SAXSource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SAXSource.java 2000/11/15 22:55:46 1.6
+++ SAXSource.java 2000/11/18 01:19:14 1.7
@@ -161,7 +161,9 @@
}
/**
- * Set the system identifier for this Source.
+ * Set the system identifier for this Source. If an input source
+ * has already been set, it will set the system ID or that
+ * input source, otherwise it will create a new input source.
*
* <p>The system identifier is optional if there is a byte stream
* or a character stream, but it is still useful to provide one,
@@ -217,8 +219,8 @@
{
StreamSource ss = (StreamSource)source;
InputSource isource= new InputSource(ss.getSystemId());
- isource.setByteStream(ss.getByteStream());
- isource.setCharacterStream(ss.getCharacterStream());
+ isource.setByteStream(ss.getInputStream());
+ isource.setCharacterStream(ss.getReader());
isource.setPublicId(ss.getPublicId());
return isource;
}
1.6 +3 -1
xml-xalan/java/src/javax/xml/transform/sax/TemplatesHandler.java
Index: TemplatesHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/sax/TemplatesHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TemplatesHandler.java 2000/11/15 22:25:22 1.5
+++ TemplatesHandler.java 2000/11/18 01:19:14 1.6
@@ -85,7 +85,9 @@
/**
* Set the base ID (URI or system ID) for the Templates object
* created by this builder. This must be set in order to
- * resolve relative URIs in the stylesheet.
+ * resolve relative URIs in the stylesheet. This must be
+ * called before the startDocument event.
+ *
* @param baseID Base URI for this stylesheet.
*/
public void setSystemId(String systemID);
1.5 +1 -1
xml-xalan/java/src/javax/xml/transform/sax/TransformerHandler.java
Index: TransformerHandler.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/sax/TransformerHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TransformerHandler.java 2000/11/15 22:25:22 1.4
+++ TransformerHandler.java 2000/11/18 01:19:14 1.5
@@ -11,7 +11,7 @@
import org.xml.sax.ext.LexicalHandler;
/**
- * The SAXTransformerFactory provides a reference to an
+ * The TransformerHandler provides a reference to an
* object that implements this interface, and that can
* listen to SAX ContentHandler parse events and transform
* them to a Result.
1.6 +60 -29
xml-xalan/java/src/javax/xml/transform/stream/StreamResult.java
Index: StreamResult.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/stream/StreamResult.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StreamResult.java 2000/11/15 02:34:32 1.5
+++ StreamResult.java 2000/11/18 01:19:14 1.6
@@ -62,6 +62,7 @@
import java.io.OutputStream;
import java.io.Writer;
+import java.io.File;
/**
* Acts as an holder for a transformation result,
@@ -90,11 +91,11 @@
* the transformer may use instructions contained in the
* transformation instructions to control the encoding.
*
- * @param byteStream A valid OutputStream reference.
+ * @param outputStream A valid OutputStream reference.
*/
- public StreamResult(OutputStream byteStream)
+ public StreamResult(OutputStream outputStream)
{
- setByteStream(byteStream);
+ setOutputStream(outputStream);
}
/**
@@ -105,12 +106,32 @@
* there are times when it is useful to write to a character
* stream, such as when using a StringWriter.
*
- * @param characterStream A valid Writer reference.
+ * @param writer A valid Writer reference.
*/
- public StreamResult(Writer characterStream)
+ public StreamResult(Writer writer)
{
- setCharacterStream(characterStream);
+ setWriter(writer);
}
+
+ /**
+ * Construct a StreamResult from a URL.
+ *
+ * @param systemId Must be a String that conforms to the URI syntax.
+ */
+ public StreamResult(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ /**
+ * Construct a StreamResult from a File.
+ *
+ * @param f Must a non-null File reference.
+ */
+ public StreamResult(File f)
+ {
+ setSystemId(f);
+ }
/**
* Set the ByteStream that is to be written to. Normally,
@@ -118,52 +139,52 @@
* the transformer may use instructions contained in the
* transformation instructions to control the encoding.
*
- * @param byteStream A valid OutputStream reference.
+ * @param outputStream A valid OutputStream reference.
*/
- public void setByteStream(OutputStream byteStream)
+ public void setOutputStream(OutputStream outputStream)
{
- this.byteStream = byteStream;
+ this.outputStream = outputStream;
}
/**
- * Get the byte stream that was set with setByteStream.
+ * Get the byte stream that was set with setOutputStream.
*
- * @return The byte stream that was set with setByteStream, or null
- * if setByteStream or the ByteStream constructor was not called.
+ * @return The byte stream that was set with setOutputStream, or null
+ * if setOutputStream or the ByteStream constructor was not called.
*/
- public OutputStream getByteStream()
+ public OutputStream getOutputStream()
{
- return byteStream;
+ return outputStream;
}
/**
- * Set the character stream that is to be written to. Normally,
- * a stream should be used rather than a reader, so that
+ * Set the writer that is to receive the result. Normally,
+ * a stream should be used rather than a writer, so that
* the transformer may use instructions contained in the
* transformation instructions to control the encoding. However,
- * there are times when it is useful to write to a character
- * stream, such as when using a StringWriter.
+ * there are times when it is useful to write to a writer,
+ * such as when using a StringWriter.
*
- * @param characterStream A valid Writer reference.
+ * @param writer A valid Writer reference.
*/
- public void setCharacterStream(Writer characterStream)
+ public void setWriter(Writer writer)
{
- this.characterStream = characterStream;
+ this.writer = writer;
}
/**
- * Get the character stream that was set with setCharacterStream.
+ * Get the character stream that was set with setWriter.
*
- * @return The character stream that was set with setCharacterStream, or
null
- * if setCharacterStream or the CharacterStream constructor was not called.
+ * @return The character stream that was set with setWriter, or null
+ * if setWriter or the Writer constructor was not called.
*/
- public Writer getCharacterStream()
+ public Writer getWriter()
{
- return characterStream;
+ return writer;
}
/**
- * Method setSystemId Set the systemID that may be used in association
+ * Set the systemID that may be used in association
* with the byte or character stream, or, if neither is set, use
* this value as a writeable URI (probably a file name).
*
@@ -173,6 +194,16 @@
{
this.systemId = systemId;
}
+
+ /**
+ * Set the system ID from a File reference.
+ *
+ * @param f Must a non-null File reference.
+ */
+ public void setSystemId(File f)
+ {
+ this.systemId = "file:///"+f.getAbsolutePath();
+ }
/**
* Get the system identifier that was set with setSystemId.
@@ -199,10 +230,10 @@
/**
* The byte stream that is to be written to.
*/
- private OutputStream byteStream;
+ private OutputStream outputStream;
/**
* The character stream that is to be written to.
*/
- private Writer characterStream;
+ private Writer writer;
}
1.6 +49 -28
xml-xalan/java/src/javax/xml/transform/stream/StreamSource.java
Index: StreamSource.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/javax/xml/transform/stream/StreamSource.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StreamSource.java 2000/11/15 02:34:32 1.5
+++ StreamSource.java 2000/11/18 01:19:14 1.6
@@ -60,6 +60,7 @@
import java.io.InputStream;
import java.io.Reader;
+import java.io.File;
/**
* Acts as an holder for a transformation Source in the form
@@ -94,11 +95,11 @@
* setSystemId should also be called, so that relative URI references
* can be resolved.</p>
*
- * @param byteStream A valid InputStream reference to an XML stream.
+ * @param inputStream A valid InputStream reference to an XML stream.
*/
- public StreamSource(InputStream byteStream)
+ public StreamSource(InputStream inputStream)
{
- setByteStream(byteStream);
+ setInputStream(inputStream);
}
/**
@@ -111,12 +112,12 @@
* to the input stream, which allows relative URIs
* to be processed.</p>
*
- * @param byteStream A valid InputStream reference to an XML stream.
+ * @param inputStream A valid InputStream reference to an XML stream.
* @param systemId Must be a String that conforms to the URI syntax.
*/
- public StreamSource(InputStream byteStream, String systemId)
+ public StreamSource(InputStream inputStream, String systemId)
{
- setByteStream(byteStream);
+ setInputStream(inputStream);
setSystemId(systemId);
}
@@ -129,11 +130,11 @@
* of the input stream is already resolved, as in the case of
* reading XML from a StringReader.
*
- * @param characterStream A valid Reader reference to an XML character
stream.
+ * @param reader A valid Reader reference to an XML character stream.
*/
- public StreamSource(Reader characterStream)
+ public StreamSource(Reader reader)
{
- setCharacterStream(characterStream);
+ setReader(reader);
}
/**
@@ -144,12 +145,12 @@
* of the input stream is already resolved, as in the case of
* reading XML from a StringReader.
*
- * @param characterStream A valid Reader reference to an XML character
stream.
+ * @param reader A valid Reader reference to an XML character stream.
* @param systemId Must be a String that conforms to the URI syntax.
*/
- public StreamSource(Reader characterStream, String systemId)
+ public StreamSource(Reader reader, String systemId)
{
- setCharacterStream(characterStream);
+ setReader(reader);
setSystemId(systemId);
}
@@ -163,6 +164,16 @@
{
this.systemId = systemId;
}
+
+ /**
+ * Construct a StreamSource from a File.
+ *
+ * @param f Must a non-null File reference.
+ */
+ public StreamSource(File f)
+ {
+ this.systemId = "file:///"+f.getAbsolutePath();
+ }
/**
* Set the byte stream to be used as input. Normally,
@@ -174,11 +185,11 @@
* setSystemId should also be called, so that relative URL references
* can be resolved.</p>
*
- * @param byteStream A valid InputStream reference to an XML stream.
+ * @param inputStream A valid InputStream reference to an XML stream.
*/
- public void setByteStream(InputStream byteStream)
+ public void setInputStream(InputStream inputStream)
{
- this.byteStream = byteStream;
+ this.inputStream = inputStream;
}
/**
@@ -187,9 +198,9 @@
* @return The byte stream that was set with setByteStream, or null
* if setByteStream or the ByteStream constructor was not called.
*/
- public InputStream getByteStream()
+ public InputStream getInputStream()
{
- return byteStream;
+ return inputStream;
}
/**
@@ -200,22 +211,22 @@
* of the input stream is already resolved, as in the case of
* reading XML from a StringReader.
*
- * @param characterStream A valid Reader reference to an XML
CharacterStream.
+ * @param reader A valid Reader reference to an XML CharacterStream.
*/
- public void setCharacterStream(Reader characterStream)
+ public void setReader(Reader reader)
{
- this.characterStream = characterStream;
+ this.reader = reader;
}
/**
- * Get the character stream that was set with setCharacterStream.
+ * Get the character stream that was set with setReader.
*
- * @return The character stream that was set with setCharacterStream, or
null
- * if setCharacterStream or the CharacterStream constructor was not called.
+ * @return The character stream that was set with setReader, or null
+ * if setReader or the Reader constructor was not called.
*/
- public Reader getCharacterStream()
+ public Reader getReader()
{
- return characterStream;
+ return reader;
}
/**
@@ -271,6 +282,16 @@
return systemId;
}
+ /**
+ * Set the system ID from a File reference.
+ *
+ * @param f Must a non-null File reference.
+ */
+ public void setSystemId(File f)
+ {
+ this.systemId = "file:///"+f.toString();
+ }
+
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
@@ -288,11 +309,11 @@
/**
* The byte stream for this Source, or null.
*/
- private InputStream byteStream;
+ private InputStream inputStream;
/**
* The character stream for this Source, or null.
*/
- private Reader characterStream;
-
+ private Reader reader;
+
}
1.53 +18 -6
xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- TransformerImpl.java 2000/11/16 08:14:13 1.52
+++ TransformerImpl.java 2000/11/18 01:19:14 1.53
@@ -1110,10 +1110,20 @@
{
Serializer serializer = SerializerFactory.getSerializer(format);
- if (null != sresult.getCharacterStream())
- serializer.setWriter(sresult.getCharacterStream());
- else
- serializer.setOutputStream(sresult.getByteStream());
+ if (null != sresult.getWriter())
+ serializer.setWriter(sresult.getWriter());
+ else if (null != sresult.getOutputStream())
+ serializer.setOutputStream(sresult.getOutputStream());
+ else if(null != sresult.getSystemId())
+ {
+ String fileURL = sresult.getSystemId();
+ if(fileURL.startsWith("file:///"))
+ {
+ fileURL = fileURL.substring(8);
+ }
+ serializer.setOutputStream(new java.io.FileOutputStream(fileURL));
+ }
+ else throw new TransformerException("No output specified!");
handler = serializer.asContentHandler();
@@ -1470,6 +1480,8 @@
return null;
}
}
+
+
/**
* Set a bag of parameters for the transformation. Note that
@@ -1485,7 +1497,7 @@
*/
public void setParameters(Properties params)
{
- resetParameters();
+ clearParameters();
Enumeration names = params.propertyNames();
while(names.hasMoreElements())
{
@@ -1512,7 +1524,7 @@
/**
* Reset the parameters to a null list.
*/
- public void resetParameters()
+ public void clearParameters()
{
VariableStack varstack = new VariableStack();
getXPathContext().setVarStack(varstack);