From cdc40905ce50878dc894a27f6d30661517e59ad4 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 9 Sep 2008 02:37:58 +0000 Subject: Creating a branch for the android work. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@693346 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/javax/xml/transform/Result.java | 70 ++++++++ .../src/javax/xml/transform/Source.java | 36 ++++ .../src/javax/xml/transform/dom/DOMSource.java | 122 +++++++++++++ .../src/javax/xml/transform/sax/SAXSource.java | 195 +++++++++++++++++++++ 4 files changed, 423 insertions(+) create mode 100644 branches/sca-android/android-jdk-classes/src/javax/xml/transform/Result.java create mode 100644 branches/sca-android/android-jdk-classes/src/javax/xml/transform/Source.java create mode 100644 branches/sca-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java create mode 100644 branches/sca-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java (limited to 'branches/sca-android/android-jdk-classes/src/javax/xml/transform') diff --git a/branches/sca-android/android-jdk-classes/src/javax/xml/transform/Result.java b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/Result.java new file mode 100644 index 0000000000..dd3517c8cc --- /dev/null +++ b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/Result.java @@ -0,0 +1,70 @@ +// $Id: Result.java,v 1.2 2003/10/22 03:53:16 jsuttor Exp $ + +/* + * @(#)Result.java 1.13 04/07/26 + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package javax.xml.transform; + +/** + *

An object that implements this interface contains the information + * needed to build a transformation result tree.

+ * + * @author Jeff Suttor + */ +public interface Result { + + /** + * The name of the processing instruction that is sent if the + * result tree disables output escaping. + * + *

Normally, result tree serialization escapes & and < (and + * possibly other characters) when outputting text nodes. + * This ensures that the output is well-formed XML. However, + * it is sometimes convenient to be able to produce output that is + * almost, but not quite well-formed XML; for example, + * the output may include ill-formed sections that will + * be transformed into well-formed XML by a subsequent non-XML aware + * process. If a processing instruction is sent with this name, + * serialization should be output without any escaping.

+ * + *

Result DOM trees may also have PI_DISABLE_OUTPUT_ESCAPING and + * PI_ENABLE_OUTPUT_ESCAPING inserted into the tree.

+ * + * @see disable-output-escaping in XSLT Specification + */ + public static final String PI_DISABLE_OUTPUT_ESCAPING = + "javax.xml.transform.disable-output-escaping"; + + /** + * The name of the processing instruction that is sent + * if the result tree enables output escaping at some point after having + * received a PI_DISABLE_OUTPUT_ESCAPING processing instruction. + * + * @see disable-output-escaping in XSLT Specification + */ + public static final String PI_ENABLE_OUTPUT_ESCAPING = + "javax.xml.transform.enable-output-escaping"; + + /** + * Set the system identifier for this Result. + * + *

If the Result is not to be written to a file, the system identifier is optional. + * The application may still want to provide one, however, for use in error messages + * and warnings, or to resolve relative output identifiers.

+ * + * @param systemId The system identifier as a URI string. + */ + public void setSystemId(String systemId); + + /** + * Get the system identifier that was set with setSystemId. + * + * @return The system identifier that was set with setSystemId, + * or null if setSystemId was not called. + */ + public String getSystemId(); +} diff --git a/branches/sca-android/android-jdk-classes/src/javax/xml/transform/Source.java b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/Source.java new file mode 100644 index 0000000000..5467229cc7 --- /dev/null +++ b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/Source.java @@ -0,0 +1,36 @@ +// $Id: Source.java,v 1.2 2003/09/07 23:02:09 jsuttor Exp $ +/* + * @(#)Source.java 1.14 04/07/26 + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package javax.xml.transform; + +/** + * An object that implements this interface contains the information + * needed to act as source input (XML source or transformation instructions). + */ +public interface Source { + + /** + * Set the system identifier for this Source. + * + *

The system identifier is optional if the source does not + * get its data from a URL, but it may still be useful to provide one. + * The application can use a system identifier, for example, to resolve + * relative URIs and to include in error messages and warnings.

+ * + * @param systemId The system identifier as a URL string. + */ + public void setSystemId(String systemId); + + /** + * Get the system identifier that was set with setSystemId. + * + * @return The system identifier that was set with setSystemId, or null + * if setSystemId was not called. + */ + public String getSystemId(); +} diff --git a/branches/sca-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java new file mode 100644 index 0000000000..a55864a04c --- /dev/null +++ b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/dom/DOMSource.java @@ -0,0 +1,122 @@ +// $Id: DOMSource.java,v 1.5.14.1.2.2 2004/07/13 22:27:49 jsuttor Exp $ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/* + * @(#)DOMSource.java 1.16 04/07/13 + */ +package javax.xml.transform.dom; + +import javax.xml.transform.Source; + +import org.w3c.dom.Node; + +/** + *

Acts as a holder for a transformation Source tree in the + * form of a Document Object Model (DOM) tree.

+ * + *

Note that XSLT requires namespace support. Attempting to transform a DOM + * that was not contructed with a namespace-aware parser may result in errors. + * Parsers can be made namespace aware by calling + * {@link javax.xml.parsers.DocumentBuilderFactory#setNamespaceAware(boolean awareness)}.

+ * + * @author Jeff Suttor + * @version $Revision: 1.5.14.1.2.2 $, $Date: 2004/07/13 22:27:49 $ + * @see Document Object Model (DOM) Level 2 Specification + */ +public class DOMSource implements Source { + + /** + *

Node to serve as DOM source.

+ */ + private Node node; + + /** + *

The base ID (URL or system ID) from where URLs + * will be resolved.

+ */ + private String systemID; + + /** If {@link javax.xml.transform.TransformerFactory#getFeature} + * returns true when passed this value as an argument, + * the Transformer supports Source input of this type. + */ + public static final String FEATURE = + "http://javax.xml.transform.dom.DOMSource/feature"; + + /** + *

Zero-argument default constructor. If this constructor is used, and + * no DOM source is set using {@link #setNode(Node node)} , then the + * Transformer will + * create an empty source {@link org.w3c.dom.Document} using + * {@link javax.xml.parsers.DocumentBuilder#newDocument()}.

+ * + * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget) + */ + public DOMSource() { } + + /** + * Create a new input source with a DOM node. The operation + * will be applied to the subtree rooted at this node. In XSLT, + * a "/" pattern still means the root of the tree (not the subtree), + * and the evaluation of global variables and parameters is done + * from the root node also. + * + * @param n The DOM node that will contain the Source tree. + */ + public DOMSource(Node n) { + setNode(n); + } + + /** + * Create a new input source with a DOM node, and with the + * system ID also passed in as the base URI. + * + * @param node The DOM node that will contain the Source tree. + * @param systemID Specifies the base URI associated with node. + */ + public DOMSource(Node node, String systemID) { + setNode(node); + setSystemId(systemID); + } + + /** + * Set the node that will represents a Source DOM tree. + * + * @param node The node that is to be transformed. + */ + public void setNode(Node node) { + this.node = node; + } + + /** + * Get the node that represents a Source DOM tree. + * + * @return The node that is to be transformed. + */ + public Node getNode() { + return node; + } + + /** + * Set the base ID (URL or system ID) from where URLs + * will be resolved. + * + * @param systemID Base URL for this DOM tree. + */ + public void setSystemId(String systemID) { + this.systemID = systemID; + } + + /** + * Get the base ID (URL or system ID) from where URLs + * will be resolved. + * + * @return Base URL for this DOM tree. + */ + public String getSystemId() { + return this.systemID; + } +} diff --git a/branches/sca-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java new file mode 100644 index 0000000000..cc09fee0ae --- /dev/null +++ b/branches/sca-android/android-jdk-classes/src/javax/xml/transform/sax/SAXSource.java @@ -0,0 +1,195 @@ +// $Id: SAXSource.java,v 1.7.14.1.2.2 2004/07/13 22:27:50 jsuttor Exp $ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/* + * @(#)SAXSource.java 1.15 04/07/13 + */ +package javax.xml.transform.sax; + +import javax.xml.transform.Source; +//import javax.xml.transform.stream.StreamSource; + +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +/** + *

Acts as an holder for SAX-style Source.

+ * + *

Note that XSLT requires namespace support. Attempting to transform an + * input source that is not + * generated with a namespace-aware parser may result in errors. + * Parsers can be made namespace aware by calling the + * {@link javax.xml.parsers.SAXParserFactory#setNamespaceAware(boolean awareness)} method.

+ * + * @author Jeff Suttor + * @version $Revision: 1.7.14.1.2.2 $, $Date: 2004/07/13 22:27:50 $ + */ +public class SAXSource implements Source { + + /** + * If {@link javax.xml.transform.TransformerFactory#getFeature} + * returns true when passed this value as an argument, + * the Transformer supports Source input of this type. + */ + public static final String FEATURE = + "http://javax.xml.transform.sax.SAXSource/feature"; + + /** + *

Zero-argument default constructor. If this constructor is used, and + * no SAX source is set using + * {@link #setInputSource(InputSource inputSource)} , then the + * Transformer will + * create an empty source {@link org.xml.sax.InputSource} using + * {@link org.xml.sax.InputSource#InputSource() new InputSource()}.

+ * + * @see javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget) + */ + public SAXSource() { } + + /** + * Create a SAXSource, using an {@link org.xml.sax.XMLReader} + * and a SAX InputSource. The {@link javax.xml.transform.Transformer} + * or {@link javax.xml.transform.sax.SAXTransformerFactory} will set itself + * to be the reader's {@link org.xml.sax.ContentHandler}, and then will call + * reader.parse(inputSource). + * + * @param reader An XMLReader to be used for the parse. + * @param inputSource A SAX input source reference that must be non-null + * and that will be passed to the reader parse method. + */ + public SAXSource(XMLReader reader, InputSource inputSource) { + this.reader = reader; + this.inputSource = inputSource; + } + + /** + * Create a SAXSource, using a SAX InputSource. + * The {@link javax.xml.transform.Transformer} or + * {@link javax.xml.transform.sax.SAXTransformerFactory} creates a + * reader via {@link org.xml.sax.helpers.XMLReaderFactory} + * (if setXMLReader is not used), sets itself as + * the reader's {@link org.xml.sax.ContentHandler}, and calls + * reader.parse(inputSource). + * + * @param inputSource An input source reference that must be non-null + * and that will be passed to the parse method of the reader. + */ + public SAXSource(InputSource inputSource) { + this.inputSource = inputSource; + } + + /** + * Set the XMLReader to be used for the Source. + * + * @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. + * + * @return A valid XMLReader or XMLFilter reference, or null. + */ + public XMLReader getXMLReader() { + return reader; + } + + /** + * Set the SAX InputSource to be used for the Source. + * + * @param inputSource A valid InputSource reference. + */ + public void setInputSource(InputSource inputSource) { + this.inputSource = inputSource; + } + + /** + * Get the SAX InputSource to be used for the Source. + * + * @return A valid InputSource reference, or null. + */ + public InputSource getInputSource() { + return inputSource; + } + + /** + * Set the system identifier for this Source. If an input source + * has already been set, it will set the system ID or that + * input source, otherwise it will create a new input source. + * + *

The system identifier is optional if there is a byte stream + * or a character stream, but it is still useful to provide one, + * since the application can use it to resolve relative URIs + * and can include it in error messages and warnings (the parser + * will attempt to open a connection to the URI only if + * no byte stream or character stream is specified).

+ * + * @param systemId The system identifier as a URI string. + */ + public void setSystemId(String systemId) { + + if (null == inputSource) { + inputSource = new InputSource(systemId); + } else { + inputSource.setSystemId(systemId); + } + } + + /** + *

Get the base ID (URI or system ID) from where URIs + * will be resolved.

+ * + * @return Base URL for the Source, or null. + */ + public String getSystemId() { + + if (inputSource == null) { + return null; + } else { + return inputSource.getSystemId(); + } + } + + /** + * The XMLReader to be used for the source tree input. May be null. + */ + private XMLReader reader; + + /** + *

The SAX InputSource to be used for the source tree input. + * Should not be null.

+ */ + private InputSource inputSource; +/* + *//** + * Attempt to obtain a SAX InputSource object from a 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.getInputStream()); + isource.setCharacterStream(ss.getReader()); + isource.setPublicId(ss.getPublicId()); + + return isource; + } else { + return null; + } + }*/ +} + -- cgit v1.2.3