sboag 00/11/03 15:22:14
Added: java/src/javax/xml/transform Features.java Result.java
Source.java SourceLocator.java
TFactoryConfigurationError.java Templates.java
Transformer.java
TransformerConfigurationException.java
TransformerException.java TransformerFactory.java
URIResolver.java package.html trax.properties
java/src/javax/xml/transform/dom DOMLocator.java
DOMResult.java DOMSource.java
java/src/javax/xml/transform/sax SAXResult.java
SAXSource.java SAXTransformerFactory.java
SerializerHandler.java TemplatesHandler.java
TransformerHandler.java
java/src/javax/xml/transform/stream OutputKeys.java
StreamResult.java StreamSource.java
Log:
The javax.xml.transform
package is the reborn TrAX.
Changed factory exception classes to be closer to JSR63 parser stuff.
Revision Changes Path
1.1 xml-xalan/java/src/javax/xml/transform/Features.java
Index: Features.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
/**
* This class defines feature URLs that are supported by
* the TrAX subpackages, such as sax, dom, etc. Using these
* values allows the transformer to do an identity comparison
* instead of a lexical comparison, which can greatly improve
* the performance of TransformerFactory#getFeature.
*/
public class Features
{
/**
* If TransformerFactory#getFeature returns true with this value
* passed as a parameter, the transformer supports the interfaces
* found in the javax.xml.transform.sax package.
*/
public static final String SAX = "http://xml.org/trax/features/sax";
/**
* If TransformerFactory#getFeature returns true with this value
* passed as a parameter, the transformer supports the interfaces
* found in the javax.xml.transform.dom package.
*/
public static final String DOM = "http://xml.org/trax/features/dom";
/**
* If TransformerFactory#getFeature returns true with this value
* passed as a parameter, the transformer supports the interfaces
* found in the javax.xml.transform.stream package.
*/
public static final String STREAM = "http://xml.org/trax/features/stream";
}
1.1 xml-xalan/java/src/javax/xml/transform/Result.java
Index: Result.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
import java.lang.String;
import java.io.OutputStream;
import java.io.Writer;
/**
* An object that implements this interface contains the information
* needed to build a result tree for a transformation.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface Result
{
}
1.1 xml-xalan/java/src/javax/xml/transform/Source.java
Index: Source.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
import java.lang.String;
import java.io.InputStream;
import java.io.Reader;
/**
* An object that implements this interface contains the information
* needed to act as source input.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface Source
{
/**
* Get the base ID (URL or system ID) of the source tree.
*
* <p>Editor's note: this method will probably go away from
* this level, be we ought to have some discussion of what
* it is on the mailing list. I'm of mixed emotions.
* It is really an aid to implementors.</p>
*
* <p>The baseID value may be set automatically by
* the derived class. For instance, in a StreamSource, the
* baseID property is the same as the SystemID property.
* For an SAXSource, the baseID property is the same as
* the InputSource's SystemID property. Other Source derivations,
* such as DOMSource, may have a specific method to set the
* baseID.</p>
*
* @return Base URL for the source tree.
*/
public String getBaseID();
}
1.1 xml-xalan/java/src/javax/xml/transform/SourceLocator.java
Index: SourceLocator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
/**
* This interface is primarily for the purposes of reporting where
* an error occured in the source or transformation instructions.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface SourceLocator
{
/**
* Return the public identifier for the current document event.
*
* <p>The return value is the public identifier of the document
* entity or of the external parsed entity in which the markup
* triggering the event appears.</p>
*
* @return A string containing the public identifier, or
* null if none is available.
* @see #getSystemId
*/
public String getPublicId();
/**
* Return the system identifier for the current document event.
*
* <p>The return value is the system identifier of the document
* entity or of the external parsed entity in which the markup
* triggering the event appears.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @return A string containing the system identifier, or null
* if none is available.
* @see #getPublicId
*/
public String getSystemId();
/**
* Return the line number where the current document event ends.
*
* <p><strong>Warning:</strong> The return value from the method
* is intended only as an approximation for the sake of error
* reporting; it is not intended to provide sufficient information
* to edit the character content of the original XML document.</p>
*
* <p>The return value is an approximation of the line number
* in the document entity or external parsed entity where the
* markup triggering the event appears.</p>
*
* @return The line number, or -1 if none is available.
* @see #getColumnNumber
*/
public int getLineNumber();
/**
* Return the column number where the current document event ends.
*
* <p><strong>Warning:</strong> The return value from the method
* is intended only as an approximation for the sake of error
* reporting; it is not intended to provide sufficient information
* to edit the character content of the original XML document.</p>
*
* <p>The return value is an approximation of the column number
* in the document entity or external parsed entity where the
* markup triggering the event appears.</p>
*
* @return The column number, or -1 if none is available.
* @see #getLineNumber
*/
public int getColumnNumber();
}
1.1
xml-xalan/java/src/javax/xml/transform/TFactoryConfigurationError.java
Index: TFactoryConfigurationError.java
===================================================================
/*
* $Id: TFactoryConfigurationError.java,v 1.1 2000/11/03 23:22:10 sboag Exp $
*
* Copyright (c) 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*/
package javax.xml.transform;
/**
* Thrown when a problem with configuration with the Parser Factories
* exists. This error will typically be thrown when the class of a
* parser factory specified in the system properties cannot be found
* or instantiated.
*
* @version 1.0
*/
public class TFactoryConfigurationError extends Error {
private Exception exception;
/**
* Create a new <code>TFactoryConfigurationError</code> with no
* detail mesage.
*/
public TFactoryConfigurationError() {
super();
this.exception = null;
}
/**
* Create a new <code>TFactoryConfigurationError</code> with
* the <code>String </code> specified as an error message.
*
* @param msg The error message for the exception.
*/
public TFactoryConfigurationError(String msg) {
super(msg);
this.exception = null;
}
/**
* Create a new <code>TFactoryConfigurationError</code> with a
* given <code>Exception</code> base cause of the error.
*
* @param e The exception to be encapsulated in a
* TFactoryConfigurationError.
*/
public TFactoryConfigurationError(Exception e) {
super();
this.exception = e;
}
/**
* Create a new <code>TFactoryConfigurationError</code> with the
* given <code>Exception</code> base cause and detail message.
*
* @param e The exception to be encapsulated in a
* TFactoryConfigurationError
* @param msg The detail message.
* @param e The exception to be wrapped in a TFactoryConfigurationError
*/
public TFactoryConfigurationError(Exception e, String msg) {
super(msg);
this.exception = e;
}
/**
* Return the message (if any) for this error . If there is no
* message for the exception and there is an encapsulated
* exception then the message of that exception will be returned.
*
* @return The error message.
*/
public String getMessage () {
String message = super.getMessage ();
if (message == null && exception != null) {
return exception.getMessage();
}
return message;
}
/**
* Return the actual exception (if any) that caused this exception to
* be raised.
*
* @return The encapsulated exception, or null if there is none.
*/
public Exception getException () {
return exception;
}
}
1.1 xml-xalan/java/src/javax/xml/transform/Templates.java
Index: Templates.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
import java.util.Properties;
import javax.xml.transform.TransformerException;
/**
* The Templates object is the runtime representation of processed
* transformation instructions.
*
* <p>Templates must be threadsafe for a given instance
* over multiple threads concurrently, and are generally meant to
* be used multiple times in a given session.</p>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface Templates
{
/**
* Create a new transformation context for this Templates object.
*
* @return A valid non-null instance of a Transformer.
*
* @throws TransformerConfigurationException if a Transformer can not be
created.
*/
Transformer newTransformer() throws TransformerConfigurationException;
/**
* Get the static properties for xsl:output. The object returned will
* be a clone of the internal values, and thus it can be mutated
* without mutating the Templates object, and then handed in to
* the process method.
*
* <p>For XSLT, Attribute Value Templates attribute values will
* be returned unexpanded (since there is no context at this point).</p>
*
* @return A Properties object, never null.
*/
Properties getOutputProperties();
}
1.1 xml-xalan/java/src/javax/xml/transform/Transformer.java
Index: Transformer.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
import java.util.Properties;
/**
* This object represents a Transformer, which can transform a
* source tree into a result tree.
*
* <p>An instance of this class can be obtained from the <code>
* TransformerFactory.newTransformer</code> method. Once an instance
* of this class is obtained, XML can be processed from a variety
* of sources with the output from the transform being written
* to a variety of sinks.</p>
*
* <p>An object of this class can not be used concurrently over
* multiple threads.</p>
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
* @since JAXP 1.1
*/
public abstract class Transformer
{
/**
* Process the source tree to the output result.
* @param xmlSource The input for the source tree.
* @param outputTarget The output source target.
*
* @throws TransformerException
*/
public abstract void transform(Source xmlSource, Result outputTarget)
throws TransformerException;
/**
* Add a parameter for the transformation.
*
* @param name The name of the parameter,
* which may have a namespace URI.
* @param value The value object. This can be any valid Java object
* -- it's up to the processor to provide the proper
* coersion to the object, or simply pass it on for use
* in extensions.
*/
public abstract void setParameter(String name, Object value);
/**
* Get a parameter that was explicitly set with setParameter
* or setParameters.
*
* @return A parameter that has been set with setParameter
* or setParameters,
* *not* all the xsl:params on the stylesheet (which require
* a transformation Source to be evaluated).
*/
public abstract Object getParameter(String name);
/**
* Set a bag of parameters for the transformation. Note that
* these will not be additive, they will replace the existing
* set of parameters.
*
* @param name The name of the parameter,
* which may have a namespace URI.
* @param value The value object. This can be any valid Java object
* -- it's up to the processor to provide the proper
* coersion to the object, or simply pass it on for use
* in extensions.
*/
public abstract void setParameters(Properties params);
/**
* Set an object that will be used to resolve URIs used in
* document(), etc.
*
* @param resolver An object that implements the URIResolver interface,
* or null.
*/
public abstract void setURIResolver(URIResolver resolver);
/**
* Set the output properties for the transformation. These
* properties will override properties set in the templates
* with xsl:output.
*
* <p>If argument to this function is null, any properties
* previously set will be removed.</p>
*
* @param oformat A set of output properties that will be
* used to override any of the same properties in effect
* for the transformation.
*
* @see org.xml.serialize.OutputFormat
*/
public abstract void setOutputProperties(Properties oformat);
/**
* Method setProperty
*
* @param name
* @param value
*
* @throws TransformerConfigurationException
*/
public abstract void setOutputProperty(String name, String value)
throws TransformerException;
/**
* Method getProperty
*
* @param name
*
* @return
*
* @throws TransformerConfigurationException
*/
public abstract String getOutputProperty(String name)
throws TransformerException;
}
1.1
xml-xalan/java/src/javax/xml/transform/TransformerConfigurationException.java
Index: TransformerConfigurationException.java
===================================================================
/*
* $Id: TransformerConfigurationException.java,v 1.1 2000/11/03 23:22:10
sboag Exp $
*
* Copyright (c) 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*/
package javax.xml.transform;
/**
* Indicates a serious configuration error.
*
* @since JAXP 1.0
* @version 1.0
*/
public class TransformerConfigurationException extends Exception {
private Exception exception;
/**
* Create a new <code>TransformerConfigurationException</code> with no
* detail mesage.
*/
public TransformerConfigurationException() {
super();
}
/**
* Create a new <code>TransformerConfigurationException</code> with
* the <code>String </code> specified as an error message.
*
* @param msg The error message for the exception.
*/
public TransformerConfigurationException(String msg) {
super(msg);
}
/**
* Create a new <code>TransformerConfigurationException</code> with a
* given <code>Exception</code> base cause of the error.
*
* @param e The exception to be encapsulated in a
* TransformerConfigurationException.
*/
public TransformerConfigurationException(Exception e) {
super();
this.exception = e;
}
/**
* Create a new <code>TransformerConfigurationException</code> with the
* given <code>Exception</code> base cause and detail message.
*
* @param e The exception to be encapsulated in a
* TransformerConfigurationException
* @param msg The detail message.
* @param e The exception to be wrapped in a
TransformerConfigurationException
*/
public TransformerConfigurationException(String msg, Exception e) {
super(msg);
this.exception = e;
}
/**
* Return the message (if any) for this error . If there is no
* message for the exception and there is an encapsulated
* exception then the message of that exception will be returned.
*
* @return The error message.
*/
public String getMessage () {
String message = super.getMessage ();
if (message == null && exception != null) {
return exception.getMessage();
}
return message;
}
/**
* Return the actual exception (if any) that caused this exception to
* be raised.
*
* @return The encapsulated exception, or null if there is none.
*/
public Exception getException () {
return exception;
}
}
1.1
xml-xalan/java/src/javax/xml/transform/TransformerException.java
Index: TransformerException.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
import javax.xml.transform.SourceLocator;
/**
* This class specifies an exceptional condition that occured
* during the transformation process.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class TransformerException extends Exception
{
/** Field locator specifies where the error occured */
SourceLocator locator;
/**
* Method getLocator retrieves and instance of a SourceLocator
* object that specifies where an error occured.
*
* @return A SourceLocator object, or null if none was specified.
*/
public SourceLocator getLocator()
{
return locator;
}
/** Field containedException specifies a wrapped exception. May be null. */
Exception containedException;
/**
* Method getException retrieves an exception that this exception wraps.
*
* @return An Exception object, or null.
*/
public Exception getException()
{
return containedException;
}
/**
* Create a new TransformerException.
*
* @param message The error or warning message.
*/
public TransformerException(String message)
{
super(message);
this.containedException = null;
this.locator = null;
}
/**
* Create a new TransformerException wrapping an existing exception.
*
* @param e The exception to be wrapped.
*/
public TransformerException(Exception e)
{
super("TRaX Transform Exception");
this.containedException = e;
this.locator = null;
}
/**
* Wrap an existing exception in a TransformerException.
*
* <p>This is used for throwing processor exceptions before
* the processing has started.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param e Any exception
*/
public TransformerException(String message, Exception e)
{
super("TRaX Transform Exception");
this.containedException = e;
this.locator = null;
}
/**
* Create a new TransformerException from a message and a Locator.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback.</p>
*
* @param message The error or warning message.
* @param locator The locator object for the error or warning.
*/
public TransformerException(String message, SourceLocator locator)
{
super(message);
this.containedException = null;
this.locator = locator;
}
/**
* Wrap an existing exception in a TransformerException.
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param locator The locator object for the error or warning.
* @param e Any exception
*/
public TransformerException(String message, SourceLocator locator,
Exception e)
{
super(message);
this.containedException = e;
this.locator = locator;
}
}
1.1
xml-xalan/java/src/javax/xml/transform/TransformerFactory.java
Index: TransformerFactory.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Properties;
import java.util.Enumeration;
/**
* A TransformerFactory instance creates Transformer and Template
* objects.
*
* A particular TransformerFactory is "plugged" into the platform via
* Processor in one of two ways: 1) as a platform default,
* and 2) through external specification by a system property named
* "javax.xml.transform.xslt" obtained using java.lang.System.getProperty().
* Or, a given application may set a platform default factory name, which
* will be used if no system property is found.
* A derived class with the specified name shall implement a
* public no-args constructor used by the base abstract class to
* create a concrete instance of this class.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public abstract class TransformerFactory
{
/** The default property name according to the JAXP spec */
private static final String defaultPropName =
"javax.xml.transform.TransformerFactory";
/**
* Default constructor is protected on purpose.
*/
protected TransformerFactory(){}
/**
* Obtain a new instance of a <code>Transform Factory</code>.
* This static method creates a new factory instance based
* on a system property setting or uses the platform default
* if no property has been defined.<p>
*
* The system property that controls which Factory implementation
* to create is named "javax.xml.transform.TransformerFactory".
* This property names a class that is a concrete subclass of this
* abstract class. If no property is defined, a platform default
* will be used.</p>
*
* Once an application has obtained a reference to a <code>
* TransformerFactory</code> it can use the factory to configure
* and obtain parser instances.
*
* @return new TransformerFactory instance, never null.
*
* @exception javax.xml.parsers.TransformerConfigurationException
* if the implmentation is not available or cannot be instantiated.
*
* @throws TransformerConfigurationException
*/
public static TransformerFactory newInstance()
throws TFactoryConfigurationError
{
String classname = findFactory(defaultPropName, null);
if (classname == null)
{
throw new TFactoryConfigurationError(
"No default implementation found");
}
TransformerFactory factoryImpl;
try
{
Class clazz = Class.forName(classname);
factoryImpl = (TransformerFactory) clazz.newInstance();
}
catch (ClassNotFoundException cnfe)
{
throw new TFactoryConfigurationError(cnfe);
}
catch (IllegalAccessException iae)
{
throw new TFactoryConfigurationError(iae);
}
catch (InstantiationException ie)
{
throw new TFactoryConfigurationError(ie);
}
return factoryImpl;
}
/**
* Process the source into a Transformer object. Care must
* be given to know that this object can not be used concurrently
* in multiple threads.
*
* @param source An object that holds a URL, input stream, etc.
*
* @return A Transformer object capable of
* being used for transformation purposes in a single thread, never null.
*
* @exception TransformerConfigurationException May throw this during the
parse when it
* is constructing the Templates object and fails.
*/
public abstract Transformer newTransformer(Source source)
throws TransformerConfigurationException;
/**
* Create a new Transformer object that performs a copy
* of the source to the result.
*
* @param source An object that holds a URL, input stream, etc.
*
* @return A Transformer object capable of
* being used for transformation purposes in a single thread, never null.
*
* @exception TransformerConfigurationException May throw this during
* the parse when it is constructing the
* Templates object and it fails.
*/
public abstract Transformer newTransformer()
throws TransformerConfigurationException;
/**
* Process the source into a Templates object, which is likely
* a compiled representation of the source. This Templates object
* may then be used concurrently across multiple threads. Creating
* a Templates object allows the TransformerFactory to do detailed
* performance optimization of transformation instructions, without
* penalizing runtime transformation.
*
* @param source An object that holds a URL, input stream, etc.
*
* @return A Templates object capable of being used for transformation
purposes,
* never null.
*
* @exception TransformerConfigurationException May throw this during the
parse when it
* is constructing the Templates object and fails.
*/
public abstract Templates newTemplates(Source source)
throws TransformerConfigurationException;
/**
* Set an object that will be used to resolve URIs used in
* xsl:import, etc. This will be used as the default for the
* transformation.
* @param resolver An object that implements the URIResolver interface,
* or null.
*/
public abstract void setURIResolver(URIResolver resolver);
/**
* Set an object that will be used to resolve URIs used in
* xsl:import, etc. This will be used as the default for the
* transformation.
*
* @return The URIResolver that was set with setURIResolver.
*/
public abstract URIResolver getURIResolver();
//======= CONFIGURATION METHODS =======
/**
* Look up the value of a feature.
*
* <p>The feature name is any fully-qualified URI.</p>
* @param name The feature name, which is a fully-qualified
* URI.
* @return The current state of the feature (true or false).
*/
public abstract boolean getFeature(String name);
/**
* Allows the user to set specific attributes on the underlying
* implementation.
* @param name The name of the attribute.
* @param value The value of the attribute.
* @exception IllegalArgumentException thrown if the underlying
* implementation doesn't recognize the attribute.
*/
public abstract void setAttribute(String name, Object value)
throws IllegalArgumentException;
/**
* Allows the user to retrieve specific attributes on the underlying
* implementation.
* @param name The name of the attribute.
* @return value The value of the attribute.
* @exception IllegalArgumentException thrown if the underlying
* implementation doesn't recognize the attribute.
*/
public abstract Object getAttribute(String name)
throws IllegalArgumentException;
// -------------------- private methods --------------------
/**
* Avoid reading all the files when the findFactory
* method is called the second time ( cache the result of
* finding the default impl )
*/
private static String foundFactory = null;
/**
* Temp debug code - this will be removed after we test everything
*/
private static final boolean debug = System.getProperty("jaxp.debug")
!= null;
/**
* Private implementation method - will find the implementation
* class in the specified order.
*
* @param factoryId Name of the factory interface
* @param xmlProperties Name of the properties file based on JAVA/lib
* @param defaultFactory Default implementation, if nothing else is found
*
* @return The factory class name.
*/
private static String findFactory(String factoryId, String defaultFactory)
{
if (foundFactory != null)
return foundFactory;
// Use the system property first
try
{
foundFactory = System.getProperty(factoryId);
if (foundFactory != null)
{
if (debug)
System.err.println("JAXP: found system property" + foundFactory);
return foundFactory;
}
}
catch (SecurityException se){}
// try to read from $java.home/lib/jaxp.properties
try
{
String javah = System.getProperty("java.home");
String configFile = javah + File.separator + "lib" + File.separator
+ "jaxp.properties";
File f = new File(configFile);
if (f.exists())
{
Properties props = new Properties();
props.load(new FileInputStream(f));
foundFactory = props.getProperty(factoryId);
if (debug)
System.err.println("JAXP: found java.home property "
+ foundFactory);
if (foundFactory != null)
return foundFactory;
}
}
catch (Exception ex)
{
if (debug)
ex.printStackTrace();
}
String serviceId = "META-INF/services/" + factoryId;
// try to find services in CLASSPATH
try
{
ClassLoader cl = TransformerFactory.class.getClassLoader();
InputStream is = null;
if (cl == null)
{
is = ClassLoader.getSystemResourceAsStream(serviceId);
}
else
{
is = cl.getResourceAsStream(serviceId);
}
if (is != null)
{
if (debug)
System.err.println("JAXP: found " + serviceId);
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
foundFactory = rd.readLine();
rd.close();
if (debug)
System.err.println("JAXP: loaded from services: " + foundFactory);
if (foundFactory != null &&!"".equals(foundFactory))
{
return foundFactory;
}
}
}
catch (Exception ex)
{
if (debug)
ex.printStackTrace();
}
return defaultFactory;
}
}
1.1 xml-xalan/java/src/javax/xml/transform/URIResolver.java
Index: URIResolver.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform;
/**
* <p>An interface that can be called by the processor to for turning the
* URIs used in document() and xsl:import etc into an Source object.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface URIResolver
{
/**
* This will be called by the processor when it encounters
* an xsl:include, xsl:import, or document() function.
*
* @param href An href attribute, which may be relative or absolute.
* @param base The base URI in effect when the href attribute was
encountered.
*
* @return A non-null Source object.
*
* @throws TransformerException
*/
public Source resolve(String href, String base) throws TransformerException;
}
1.1 xml-xalan/java/src/javax/xml/transform/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
</title>
</head>
<body>
<h2>Transformations API For XML (TrAX)</h2>
<p>October 30, 2000</p>
<p>©Copyright 2000 Java Community Process (Sun Microsystems,
Inc.)</p>
<h3>Introduction</h3>
<p>There is a broad need for Java applications to be able to transform XML
and related tree-shaped data structures. In fact, XML is not normally
very
useful to an application without going through some sort of
transformation,
unless the semantic structure is used directly as data. Almost all
xml-related
applications need to perform transformations. Transformations may be
described
by Java code, Perl code, XSLT Stylesheets, other types of script, or by
proprietary formats. The inputs, one or multiple, to a transformation,
may be
an URL, XML stream, a DOM tree, SAX Events, or a proprietary format or
data
structure. The output types are the pretty much the same types as the
inputs,
but different inputs may need to be combined with different
outputs.</p>
<p>The great challenge of a transformation API is how to deal with
combinations of inputs and outputs, without becoming specialized for
any of the
given types.</p>
<p>The Java community will greatly benefit from a common API that will
allow them to understand and apply a single model, write to consistent
interfaces, and apply the transformations polymorphically. TrAX
attempts to
define a model that is clean and generic, yet will fill the
requirements of
general application across a great variety of uses. </p>
<h3>General Terminology</h3>
<p>This section will explain some general terminology used in this
document. Technical terminology will be explained in the Model
section. In many
cases, the general terminology overlaps with the technical
terminology.</p>
<dl>
<dt>Transformation</dt>
<dd>The processor of consuming a stream or tree to produce
another stream or tree.</dd>
<dt>Serialization</dt>
<dd>The process of taking a tree and turning it into a stream. In
some sense, serialization is a specialization of
transformation.</dd>
<dt>Transformer</dt>
<dd>A transformer is the thing that executes the transformation.
</dd>
<dt>Transformation instructions</dt>
<dd>Describes the transformation. A form of code or
script.</dd>
<dt>Processor</dt>
<dd>A general term for the thing that may both process the
transformation instructions, and perform the
transformation.</dd>
</dl>
<h3>Requirements</h3>
<p>The following requirements have been determined from broad experience
with XML projects from the various members participating on the
JCP.</p>
<ol>
<li>TrAX must provide a clean, simple interface for simple
uses.</li>
<li>TrAX must be powerful enough to be applied to a wide range of
uses, such as, e-commerce, content management, server content
delivery, and
client applications.</li>
<li>A processor that implements a TrAX interface must be
optimizeable. Performance is a critical issue for most
transformation use
cases.</li>
<li>As a specialization of the above requirement, a TrAX processor
must be able to support a compiled model, so that a single set
of
transformation instructions can be compiled, optimized, and
applied to a large
set of input sources.</li>
<li>TrAX must not be dependent an any given type of transformation
instructions. For instance, it must remain independent of
XSLT.</li>
<li>TrAX must be able to allow processors to transform DOM
trees.</li>
<li>TrAX must be able to allow processors to produce DOM
trees.</li>
<li>TrAX must be able to allow processors to transform SAX
events.</li>
<li>TrAX must be able to allow processors to produce DOM
trees.</li>
<li>TrAX must be able to allow processors to transform streams of
XML.</li>
<li>TrAX must be able to allow processors to produce XML, HTML, and
other types of streams.</li>
<li>TrAX must be able to allow processors to implement the various
combinations of inputs and outputs within a single
processor.</li>
<li>TrAX must be able to allow processors to implement only a limited
set of inputs. For instance, it should be possible to write a
processor that
implements the TrAX interfaces that only processor DOM trees,
not streams or
SAX events.</li>
<li>TrAX should allow a processor to implement transformations of
proprietary data structures. For instance, it should be
possible to implement a
processor that provides TrAX interfaces that performs
transformation of JDOM
trees.</li>
<li>TrAX must be able to allow the setting of serialization
properties, without constraint as to what the details of those
properties
are.</li>
<li>TrAX must allow the setting of parameters to the transformation
instructions.</li>
<li>TrAX must be able to support the setting of parameters and
properties as XML Namespaced items (i.e. qualified names).</li>
<li>TrAX must be able to support URL resolution from within the
transformation, and have it return the needed data
structure.</li>
</ol>
<h3>Model</h3>
<p>The section defines the abstract model for TrAX, apart from the details
of the interfaces.</p>
<p>A TRaX TransformerFactory is an object that
processes transformation instructions, and produces
Templates (in the technical termonology). The
Templates provide Transformers, which
transform one or more Sources into one or more
Results.</p>
<p>To use the TRaX interface, you create a
TransformerFactory, which may directly provide Transformers,
or which can provide Templates from a variety of
Sources. The Templates object is normally a compiled
representation of the transformation instructions, and provides a
Transformer. The Transformer processes an
InputSource according to the instructions found in the
Templates, and produces a Result.</p>
<p>The process of transformation from a tree, either in the form of an
object model, or in the form of parse events, into a stream, is known
as
Serialization. This term, although it overlaps with Java
object serialization, is the best description of this process.</p>
ProcessorGeneric concept for the
set of objects that implement the TrAX
interfaces.Create compiled transformation
instructions, transform resources, and manager parameters and properties of
those transformations.Only the Templates
object can be used concurrently in multiple threads. The rest of the
processor
does not do synchronized blocking, and so can not be used
concurrently.
TransformerFactory Serve as a vendor
neutral Processor interface for XSLT processors and similar
processors. Serve as a factory for a concrete
implementation of an TransformerFactory, serve as a direct factory for
Transformer objects, serve as a factory for Templates objects, and manage
processor specific features.
TransformerFactorys can not run concurrently.
Templates The run
time representation of the transformation instructions.
Acts as a data bag for transformation instructions, act as a
factory for Transformers. Threadsafe
concurrently over multiple threads once construction is
complete.
Transformer Act as a per-thread execution
context for transformations, act as an interface for performing the
transformation.Perfom the
transformation. Only safe one instance per
thread. The Transformer is bound to the Templates object
that created it.
Source Serve as a single vendor-neutral
object for multiple types of input. Act as simple
data holder for System IDs, DOM nodes, streams, etc.
Threadsafe concurrently over multiple threads for read-only,
must be synchronized for edit.
Result
ResultTarget Serve
as a single object for multiple types of output, so there can be simple
process
method signatures. Act as simple data holder for
output stream, DOM node, ContentHandler, etc.
Threadsafe concurrently over multiple threads for read-only,
must be synchronized for edit.
<h3>Interfaces and Usage</h3>
<p>The detailed documentation of the APIs is left to JavaDoc
for the
moment, until the interfaces are stable enough to document
here.</p>
<p> TrAX defines a top-level series of interfaces in
org.javax.xml.trax.
These interfaces have no dependencies on SAX or the DOM
standard, and try to
make as few assumptions as possible about the details of the
source and result
of a transform. It acheaves this by defining
org.javax.xml.trax.Source and
org.javax.xml.trax.Result interfaces, which, at the current
time, hold no
methods, though this may change over time.</p>
<p>In order to define concrete, useable classes for the user, TrAX
defines specialization of the interfaces found at the TrAX root
level. These
interfaces are found in javax.xml.trax.sax, javax.xml.trax.dom,
javax.xml.trax.uri, and javax.xml.trax.stream.</p>
<h3>Creating Objects</h3>
<p>TrAX allows a concrete TransformerFactory object to be
created from
static functions implemented by the TransformerFactory
abstract class. A
particular TransformerFactory is "plugged" into the platform
via the
ProcessorFactory in one of two ways: 1) as a platform default
classname that
can be set via the TransformerFactory#setPlatformDefault
method, and 2) through
external specification by a system property named
"org.xml.trax.Processor.xslt"
obtained using java.lang.System.getProperty().</p>
<h3>Specification of Inputs and Outputs</h3>
<p>TrAX defines two interface objects called Source and Result.
In
order to pass Source and Result objects to the TrAX
interfaces, concrete
classes need to be used. TrAX defines four concrete
representations of Source
and Result pairs: URISource and URIResult, StreamSource and
StreamResult,
SAXSource and SAXResult, and DOMSource and DOMResult.</p>
<h3>Qualified Name representation</h3>
<p>One of the facts of dealing with XML objects is having to
deal
withNamespaces.
Qualified Names appear in XML markup as prefixed names. But
the prefixes
themselves do not hold identity, rather, it is the URIs that
they contextually
map to that hold the identity. Therefore, when passing
Qualified Names in among
Java programs, it is impossible to pass "xyz:foo" without
have some sort of
object that maps "xyz" to a namespace. </p>
<p>One solution to this as been to create a QName object that
holds
the namespace URI, as well as the prefix and local name. But
this is not a
great solution when you want to use unique strings as keys in
a dictionary
object, for instance. Not having a string representation also
makes it very
hard to specify namespaced identity outside the context of a
XML
document.</p>
<p>In order to pass namespaced values to transformations, for
instance
as a set of properties to the Serializer, this specification
defines that
parameter String object specified as "qname" be passed as
two-part string, with
the first part being the URL, the delimiter being the '{' for
the start of the
URI and '}' signifies the end, with the local name following.
If the qname has
a null URL, then the String object will only contain the
local name. An
application can safely check for a non-null URI by testing to
see if the first
character of the name is a '{' character.</p>
<p>For example, if a URI and local name were obtained from an
element
defined with <xyz:foo
xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>,
then the TrAX QName would be
"{http://xyz.foo.com/yada/baz.html}foo". Note that
the prefix is lost.</p>
<h3>Serialization</h3>
<p>
</p>
<p>If all that is desired is the simple identity transformation
of a
source to a result, then the TransformerFactory provides a
newTransformer
method that does not have any arguments. The method will
create a Transformer
that will simply perform a copy of the source to the result.
The most common
uses of this will be to create a DOM from SAX events, or
creates an XML or HTML
stream from DOM or SAX events. The following example
illustrates the
serialization of a DOM node to an XML stream.</p>
<code>
<pre> TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer serializer = tfactory.newTransformer();
Properties oprops = new Properties();
oprops.put("method", "html");
oprops.put("indent-amount", "2");
serializer.setOutputProperties(oprops);
serializer.transform(new DOMSource(doc),
new StreamResult(System.out));</pre>
</code>
<h3>Resolution of URIs within a transformation</h3>
<p>TBD</p>
</body>
</html>
1.1 xml-xalan/java/src/javax/xml/transform/trax.properties
Index: trax.properties
===================================================================
#
# $Revision: 1.1 $ $Date: 2000/11/03 23:22:10 $
#
# Note: This properties file is provided for illustrative purposes
# only and is not part of the interface definition.
# This properties file is located in the implementation JAR
# and different implementations will specify different
# implementation classes and output methods.
#
#
# Lis the methods supported by this implementation
#
serialize.methods=xml,html,xhtml,text,wml:wml
#
# Use the Xalan serializer implementation for the default XSLT processor
#
javax.xml.trax.processor.xslt=org.apache.xalan.processor.StylesheetProcessor
1.1
xml-xalan/java/src/javax/xml/transform/dom/DOMLocator.java
Index: DOMLocator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.dom;
import javax.xml.transform.SourceLocator;
import org.w3c.dom.Node;
/**
* Interface DOMLocator
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public interface DOMLocator extends SourceLocator
{
/**
* Method getOriginatingNode
*
* @return
*/
public Node getOriginatingNode();
}
1.1 xml-xalan/java/src/javax/xml/transform/dom/DOMResult.java
Index: DOMResult.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.dom;
import javax.xml.transform.*;
import java.lang.String;
import java.io.OutputStream;
import java.io.Writer;
import org.w3c.dom.Node;
/**
* Acts as an holder for a transformation result tree.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class DOMResult implements Result
{
/**
* Zero-argument default constructor.
*/
public DOMResult(){}
/**
* Create a new output target with a DOM node.
*
* @param n The DOM node that will contain the result tree.
*/
public DOMResult(Node n)
{
setNode(n);
}
/**
* Set the node that will contain the result DOM tree.
*
* @param node
*/
public void setNode(Node node)
{
this.node = node;
}
/**
* Get the node that will contain the result tree.
*
* @return
*/
public Node getNode()
{
return node;
}
/**
* Field node
*/
private Node node;
}
1.1 xml-xalan/java/src/javax/xml/transform/dom/DOMSource.java
Index: DOMSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.dom;
import javax.xml.transform.*;
import java.lang.String;
import java.io.OutputStream;
import java.io.Writer;
import org.w3c.dom.Node;
/**
* Acts as an holder for a transformation Source tree.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class DOMSource implements Source
{
/**
* Zero-argument default constructor.
*/
public DOMSource(){}
/**
* Create a new output target with a DOM node.
*
* @param n The DOM node that will contain the Source tree.
*/
public DOMSource(Node n)
{
setNode(n);
}
/**
* Set the node that will contain the Source DOM tree.
*
* @param node
*/
public void setNode(Node node)
{
this.node = node;
}
/**
* Get the node that will contain the Source tree.
*
* @return
*/
public Node getNode()
{
return node;
}
/**
* Field node
*/
private Node node;
/**
* The base ID (URL or system ID) from where URLs
* will be resolved.
*/
String baseID;
/**
* Set the base ID (URL or system ID) from where URLs
* will be resolved.
*
* @param baseID Base URL for this DOM tree.
*/
public void setBaseID(String baseID)
{
this.baseID = baseID;
}
/**
* Get the base ID (URL or system ID) from where URLs
* will be resolved.
*
* @return Base URL for this DOM tree.
*/
public String getBaseID()
{
return this.baseID;
}
}
1.1 xml-xalan/java/src/javax/xml/transform/sax/SAXResult.java
Index: SAXResult.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.sax;
import javax.xml.transform.*;
import java.lang.String;
import java.io.OutputStream;
import java.io.Writer;
import org.xml.sax.ContentHandler;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
/**
* Acts as an holder for a transformation result tree.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class SAXResult implements Result
{
/**
* Zero-argument default constructor.
*/
public SAXResult(){}
/**
* Create a new output target with a DOM node.
*
*
* @param handler
*/
public SAXResult(ContentHandler handler)
{
setHandler(handler);
}
/**
* Set the node that will contain the result DOM tree.
*
* @param handler
*/
public void setHandler(ContentHandler handler)
{
this.handler = handler;
}
/**
* Get the node that will contain the result tree.
*
* @return
*/
public ContentHandler getHandler()
{
return handler;
}
/**
* Set the SAX2 DeclHandler for the output.
*
* @param handler
*/
void setDeclHandler(DeclHandler handler)
{
this.declhandler = declhandler;
}
/**
* Get the SAX2 DeclHandler for the output.
* @return A DeclHandler, or null.
*/
DeclHandler getDeclHandler()
{
return declhandler;
}
/**
* Set the SAX2 LexicalHandler for the output.
*
* @param handler
*/
void setLexicalHandler(LexicalHandler handler)
{
this.lexhandler = lexhandler;
}
/**
* Get a SAX2 LexicalHandler for the output.
* @return A LexicalHandler, or null.
*/
LexicalHandler getLexicalHandler()
{
return lexhandler;
}
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
/**
* Field handler
*/
private ContentHandler handler;
/**
* Field declhandler
*/
private DeclHandler declhandler;
/**
* Field lexhandler
*/
private LexicalHandler lexhandler;
}
1.1 xml-xalan/java/src/javax/xml/transform/sax/SAXSource.java
Index: SAXSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.sax;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import java.lang.String;
import java.io.OutputStream;
import java.io.Writer;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.InputSource;
/**
* Acts as an holder for SAX-style Source tree input.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class SAXSource implements Source
{
/**
* Zero-argument default constructor.
*/
public SAXSource(){}
/**
* Create a SAXSource, using an XMLReader and an InputSource.
* The Transformer or SAXTransformerFactory will set itself
* to be the reader's content handler, and then will call
* reader.parse(inputSource).
*
* NEEDSDOC @param reader
* NEEDSDOC @param inputSource
*/
public SAXSource(XMLReader reader, InputSource inputSource)
{
this.reader = reader;
this.inputSource = inputSource;
}
/**
* Create a SAXSource, using an InputSource.
* The Transformer or SAXTransformerFactory will create a
* reader via org.xml.sax.helpers.ParserFactory
* (if setXMLReader is not used), and will set itself
* to be the content handler of that reader, and then will call
* reader.parse(inputSource).
*
* NEEDSDOC @param inputSource
*/
public SAXSource(InputSource inputSource)
{
this.inputSource = inputSource;
}
/**
* Set the XMLReader to be used for the source tree input.
*
* @param reader A valid XMLReader or XMLFilter reference.
*/
public void setXMLReader(XMLReader reader)
{
this.reader = reader;
}
/**
* Get the XMLReader to be used for the source tree input.
*
* @return A valid XMLReader or XMLFilter reference, or null.
*/
public XMLReader getXMLReader()
{
return reader;
}
/**
* Set the InputSource to be used for the source tree input.
*
* @param inputSource A valid InputSource reference.
*/
public void setInputSource(InputSource inputSource)
{
this.inputSource = inputSource;
}
/**
* Get the InputSource to be used for the source tree input.
*
* @return A valid InputSource reference, or null.
*/
public InputSource getInputSource()
{
return inputSource;
}
/** The XMLReader to be used for the source tree input. OK if null.
*/
private XMLReader reader;
/** The InputSource to be used for the source tree input. Should not be
null. */
private InputSource inputSource;
/**
* Try and obtain a SAX InputSource object from a TrAX Source
* object.
*
* @param source Must be a non-null Source reference.
*
* @return An InputSource, or null if source can not be converted.
*/
public static InputSource sourceToInputSource(Source source)
{
if(source instanceof SAXSource)
{
return ((SAXSource)source).getInputSource();
}
else if(source instanceof StreamSource)
{
StreamSource ss = (StreamSource)source;
InputSource isource= new InputSource(ss.getSystemId());
isource.setByteStream(ss.getByteStream());
isource.setCharacterStream(ss.getCharacterStream());
isource.setPublicId(ss.getPublicId());
return isource;
}
else
return null;
}
/**
* Get the base ID (URL or system ID) from where URLs
* will be resolved.
*
* @return Base URL for the source tree, or null.
*/
public String getBaseID()
{
return (null != inputSource) ? inputSource.getSystemId() : null;
}
}
1.1
xml-xalan/java/src/javax/xml/transform/sax/SAXTransformerFactory.java
Index: SAXTransformerFactory.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.sax;
import javax.xml.transform.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.XMLReader;
import org.xml.sax.ErrorHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.XMLFilter;
/**
* Interface SAXTransformerFactory
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public abstract class SAXTransformerFactory extends TransformerFactory
{
/**
* Get a TransformerHandler object that can process SAX
* ContentHandler events into a Result, based on the transformation
* instructions specified by the argument.
*
* @param src The source of the transformation instructions.
*
*
* @return TransformerHandler ready to transform SAX events.
* @throws TransformerConfigurationException
*/
public abstract TransformerHandler newTransformerHandler(Source src)
throws TransformerConfigurationException;
/**
* Get a TransformerHandler object that can process SAX
* ContentHandler events into a Result.
*
* @param src The source of the transformation instructions.
*
*
* NEEDSDOC ($objectName$) @return
* @throws TransformerConfigurationException
*/
public abstract TransformerHandler newTransformerHandler()
throws TransformerConfigurationException;
/**
* Get a TemplatesHandler object that can process SAX
* ContentHandler events into a Templates object.
*
* @param src The source of the transformation instructions.
*
*
* NEEDSDOC ($objectName$) @return
* @throws TransformerConfigurationException
*/
public abstract TemplatesHandler newTemplatesHandler()
throws TransformerConfigurationException;
/**
* Create an XMLFilter that uses the given source as the
* transformation instructions.
*
* @param src The source of the transformation instructions.
*
* @return An XMLFilter object, or null if this feature is not supported.
*/
public abstract XMLFilter newXMLFilter(Source src);
/**
* Get InputSource specification(s) that are associated with the
* given document specified in the source param,
* via the xml-stylesheet processing instruction
* (see http://www.w3.org/TR/xml-stylesheet/), and that matches
* the given criteria. Note that it is possible to return several
stylesheets
* that match the criteria, in which case they are applied as if they were
* a list of imports or cascades.
*
* @param source
* @param media The media attribute to be matched. May be null, in which
* case the prefered templates will be used (i.e. alternate =
no).
* @param title The value of the title attribute to match. May be null.
* @param charset The value of the charset attribute to match. May be null.
* @returns An array of InputSources that can be passed to processMultiple
method.
*
* @return A Source object suitable for passing to the TransformerFactory.
*
* @throws TransformerConfigurationException
*/
public abstract Source getAssociatedStylesheet(
Source source, String media, String title, String charset)
throws TransformerConfigurationException;
/** NEEDSDOC Field errorHandler */
ErrorHandler errorHandler;
/**
* Allow an application to register an error event handler.
*
* <p>If the application does not register an error handler, all
* error events reported by the SAX parser will be silently
* ignored; however, normal processing may not continue. It is
* highly recommended that all SAX applications implement an
* error handler to avoid unexpected bugs.</p>
*
* <p>Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.</p>
*
* @param handler The error handler.
* @exception java.lang.NullPointerException If the handler
* argument is null.
* @see #getErrorHandler
*/
public void setErrorHandler(ErrorHandler handler)
{
if (handler == null)
{
throw new NullPointerException("Null error handler");
}
errorHandler = handler;
}
/**
* Return the current error handler.
*
* @return The current error handler, or null if none
* has been registered.
* @see #setErrorHandler
*/
public ErrorHandler getErrorHandler()
{
return errorHandler;
}
/** NEEDSDOC Field entityResolver */
private EntityResolver entityResolver;
/**
* Allow an application to register an entity resolver.
*
* <p>If the application does not register an entity resolver,
* the XMLReader will perform its own default resolution.</p>
*
* <p>Applications may register a new or different resolver in the
* middle of a parse, and the SAX parser must begin using the new
* resolver immediately.</p>
*
* @param resolver The entity resolver.
* @exception java.lang.NullPointerException If the resolver
* argument is null.
* @see #getEntityResolver
*/
public void setEntityResolver(EntityResolver resolver)
{
entityResolver = resolver;
}
/**
* Return the current entity resolver.
*
* @return The current entity resolver, or null if none
* has been registered.
* @see #setEntityResolver
*/
public EntityResolver getEntityResolver()
{
return entityResolver;
}
}
1.1
xml-xalan/java/src/javax/xml/transform/sax/SerializerHandler.java
Index: SerializerHandler.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.sax;
/**
* Interface that supplements [EMAIL PROTECTED] org.xml.sax.DocumentHandler}
and
* [EMAIL PROTECTED] org.xml.sax.ContentHandler} with additional methods
suitable
* for serialization.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public interface SerializerHandler
{
/**
* Starts an un-escaping section. All characters printed within an
* un-escaping section are printed as is, without escaping special
* characters into entity references. Only XML and HTML serializers
* need to support this method.
* <p>
* The contents of the un-escaping section will be delivered through
* the regular <tt>characters</tt> event.
*/
public void startNonEscaping();
/**
* Ends an un-escaping section.
*
* @see #startNonEscaping
*/
public void endNonEscaping();
/**
* Starts a whitespace preserving section. All characters printed
* within a preserving section are printed without indentation and
* without consolidating multiple spaces. This is equivalent to
* the <tt>xml:space="preserve"</tt> attribute. Only XML
* and HTML serializers need to support this method.
* <p>
* The contents of the whitespace preserving section will be delivered
* through the regular <tt>characters</tt> event.
*/
public void startPreserving();
/**
* Ends a whitespace preserving section.
*
* @see #startPreserving
*/
public void endPreserving();
}
1.1
xml-xalan/java/src/javax/xml/transform/sax/TemplatesHandler.java
Index: TemplatesHandler.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.sax;
import javax.xml.transform.*;
import org.xml.sax.ContentHandler;
import org.xml.sax.ext.LexicalHandler;
/**
* This is a SAX ContentHandler that may be used to process SAX
* events into an Templates objects. This is an abstract class
* instead of an interface, so it can be a ContentHandler object,
* for passing into the JAXP SAXParser interface.
*
* <p>Note that TemplatesHandler doesn't need to implement LexicalHandler.</p>
*/
public interface TemplatesHandler extends ContentHandler
{
/**
* When this object is used as a ContentHandler or DocumentHandler, it
* creates a Templates object, which the caller can get once
* the SAX events have been completed.
*
* @return The stylesheet object that was created during
* the SAX event process, or null if no stylesheet has
* been created.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public Templates getTemplates();
/**
* Set the base ID (URL or system ID) for the stylesheet
* created by this builder. This must be set in order to
* resolve relative URLs in the stylesheet.
* @param baseID Base URL for this stylesheet.
*/
public void setBaseID(String baseID);
}
1.1
xml-xalan/java/src/javax/xml/transform/sax/TransformerHandler.java
Index: TransformerHandler.java
===================================================================
package javax.xml.transform.sax;
import java.util.Properties;
import javax.xml.transform.Result;
import javax.xml.transform.URIResolver;
import javax.xml.transform.TransformerException;
import javax.xml.transform.Transformer;
import org.xml.sax.ContentHandler;
import org.xml.sax.ext.LexicalHandler;
public interface TransformerHandler
extends ContentHandler, LexicalHandler
{
/**
* Method setResult allows the user of the TransformerHandler
* to set the result of the transform.
*
* @param result A Result instance, should not be null.
*
* @throws TransformerException if result is invalid for some reason.
*/
public void setResult(Result result)
throws TransformerException;
/**
* Set the base ID (URL or system ID) from where relative
* URLs will be resolved.
* @param baseID Base URL for the source tree.
*/
public void setBaseID(String baseID);
/**
* Get the Transformer associated with this handler, which
* is needed in order to set parameters and output properties.
*/
public Transformer getTransformer();
}
1.1
xml-xalan/java/src/javax/xml/transform/stream/OutputKeys.java
Index: OutputKeys.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.stream;
/**
* Class OutputKeys provides string constants that can be used to set
* output properties on the Transformer class, or to retrieve
* output properties on either Transformer or Templates instances.
*
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public class OutputKeys
{
/**
* method = "xml" | "html" | "text" | <var>qname-but-not-ncname</var>.
*
* <p>The method attribute identifies the overall method that
* should be used for outputting the result tree.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String METHOD = "method";
/**
* version = <var>nmtoken</var>.
*
* <p><code>version</code> specifies the version of the output
* method.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String VERSION = "version";
/**
* encoding = <var>string</var>.
*
* <p><code>encoding</code> specifies the preferred character
* encoding that the XSLT processor should use to encode sequences of
* characters as sequences of bytes; the value of the attribute should be
* treated case-insensitively; the value must contain only characters in
* the range #x21 to #x7E (i.e. printable ASCII characters); the value
* should either be a <code>charset</code> registered with the Internet
* Assigned Numbers Authority <a href="#IANA">[IANA]</a>,
* <a href="#RFC2278">[RFC2278]</a> or start with <code>X-</code>.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String ENCODING = "encoding";
/**
* omit-xml-declaration = "yes" | "no".
*
* <p><code>omit-xml-declaration</code> specifies whether the XSLT
* processor should output an XML declaration; the value must be
* <code>yes</code> or <code>no</code>.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String OMIT_XML_DECLARATION = "omit-xml-declaration";
/**
* standalone = "yes" | "no".
*
* <p><code>standalone</code> specifies whether the XSLT processor
* should output a standalone document declaration; the value must be
* <code>yes</code> or <code>no</code>.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String STANDALONE = "standalone";
/**
* doctype-public = <var>string</var>.
*
* <p><code>doctype-public</code> specifies the public identifier
* to be used in the document type declaration.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String DOCTYPE_PUBLIC = "doctype-public";
/**
* doctype-system = <var>string</var>.
*
* <p><code>doctype-system</code> specifies the system identifier
* to be used in the document type declaration.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String DOCTYPE_SYSTEM = "doctype-system";
/**
* cdata-section-elements = <var>qnames</var>.
*
* <p><code>cdata-section-elements</code> specifies a list of the
* names of elements whose text node children should be output using
* CDATA sections.</p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String CDATA_SECTION_ELEMENTS =
"cdata-section-elements";
/**
* indent = "yes" | "no".
*
* <p><code>indent</code> specifies whether the XSLT processor may
* add additional whitespace when outputting the result tree; the value
* must be <code>yes</code> or <code>no</code>. </p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String INDENT = "indent";
/**
* media-type = <var>string</var>.
*
* <p><code>media-type</code> specifies the media type (MIME
* content type) of the data that results from outputting the result
* tree; the <code>charset</code> parameter should not be specified
* explicitly; instead, when the top-level media type is
* <code>text</code>, a <code>charset</code> parameter should be added
* according to the character encoding actually used by the output
* method. </p>
* @see <a href="http://www.w3.org/TR/xslt#output">section 16 of the
* XSL Transformations (XSLT) W3C Recommendation</a>.
*/
public static final String MEDIA_TYPE = "media-type";
}
1.1
xml-xalan/java/src/javax/xml/transform/stream/StreamResult.java
Index: StreamResult.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.stream;
import javax.xml.transform.*;
import java.lang.String;
import java.io.OutputStream;
import java.io.Writer;
import org.xml.sax.ContentHandler;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
/**
* Acts as an holder for a transformation result tree.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class StreamResult implements Result
{
/**
* Zero-argument default constructor.
*/
public StreamResult(){}
/**
* Constructor StreamResult
*
* @param byteStream
*/
public StreamResult(OutputStream byteStream)
{
setByteStream(byteStream);
}
/**
* Constructor StreamResult
*
* @param characterStream
*/
public StreamResult(Writer characterStream)
{
setCharacterStream(characterStream);
}
/**
* Method setByteStream
*
* @param byteStream
*/
public void setByteStream(OutputStream byteStream)
{
this.byteStream = byteStream;
}
/**
* Method getByteStream
*
* @return
*/
public OutputStream getByteStream()
{
return byteStream;
}
/**
* Method setCharacterStream
*
* @param characterStream
*/
public void setCharacterStream(Writer characterStream)
{
this.characterStream = characterStream;
}
/**
* Method getCharacterStream
*
* @return
*/
public Writer getCharacterStream()
{
return characterStream;
}
/**
* Method setSystemId
*
* @param systemId
*/
public void setSystemId(String systemId)
{
this.systemId = systemId;
}
/**
* Method getSystemId
*
* @return
*/
public String getSystemId()
{
return systemId;
}
/**
* Field systemId
*/
private String systemId;
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
/**
* Field byteStream
*/
private OutputStream byteStream;
/**
* Field characterStream
*/
private Writer characterStream;
}
1.1
xml-xalan/java/src/javax/xml/transform/stream/StreamSource.java
Index: StreamSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package javax.xml.transform.stream;
import javax.xml.transform.Source;
import java.io.InputStream;
import java.io.Reader;
/**
* Acts as an holder for a transformation Source tree.
*
* @version Alpha
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Boag</a>
*/
public class StreamSource implements Source
{
/**
* Zero-argument default constructor.
*/
public StreamSource(){}
/**
* Constructor StreamSource
*
* @param byteStream
*/
public StreamSource(InputStream byteStream)
{
setByteStream(byteStream);
}
/**
* Constructor StreamSource
*
* @param characterStream
*/
public StreamSource(Reader characterStream)
{
setCharacterStream(characterStream);
}
/**
* Method setCharacterStream
*
* @param characterStream
*
* NEEDSDOC @param systemId
*/
public StreamSource(String systemId)
{
this.systemId = systemId;
}
/**
* Method setByteStream
*
* @param byteStream
*/
public void setByteStream(InputStream byteStream)
{
this.byteStream = byteStream;
}
/**
* Method getByteStream
*
* @return
*/
public InputStream getByteStream()
{
return byteStream;
}
/**
* Method setCharacterStream
*
* @param characterStream
*/
public void setCharacterStream(Reader characterStream)
{
this.characterStream = characterStream;
}
/**
* Method getCharacterStream
*
* @return
*/
public Reader getCharacterStream()
{
return characterStream;
}
/**
* Method setPublicId
*
* @param publicId
*/
public void setPublicId(String publicId)
{
this.publicId = publicId;
}
/**
* Method getPublicId
*
* @return
*/
public String getPublicId()
{
return publicId;
}
/**
* Method setSystemId
*
* @param systemId
*/
public void setSystemId(String systemId)
{
this.systemId = systemId;
}
/**
* Method getSystemId
*
* @return
*/
public String getSystemId()
{
return systemId;
}
/**
* Field publicId
*/
private String publicId;
/**
* Field systemId
*/
private String systemId;
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
/**
* Field byteStream
*/
private InputStream byteStream;
/**
* Field characterStream
*/
private Reader characterStream;
/**
* Get the base ID (URL or system ID) from where URLs
* will be resolved.
*
* <p>In the case of StreamSource, this will set the
* systemID value.</p>
*
* @return Base URL for the source tree.
*/
public String getBaseID()
{
return systemId;
}
}