This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicemix-bundles.git
The following commit(s) were added to refs/heads/master by this push:
new 9163d4179 SM-5608: Fix xalan 2.7.3 bundle dependency
9163d4179 is described below
commit 9163d4179e25fa70b669567c07b1541d237300c8
Author: Jean-Baptiste Onofré <[email protected]>
AuthorDate: Sat Sep 30 08:25:05 2023 +0200
SM-5608: Fix xalan 2.7.3 bundle dependency
---
pom.xml | 2 +
xalan-2.7.3/pom.xml | 6 +-
.../xalan/xsltc/runtime/AbstractTranslet.java | 5 +-
.../org/apache/xml/serializer/DOMSerializer.java | 74 +++
.../xml/serializer/ExtendedContentHandler.java | 271 +++++++++++
.../xml/serializer/ExtendedLexicalHandler.java | 39 ++
.../apache/xml/serializer/NamespaceMappings.java | 500 +++++++++++++++++++++
.../org/apache/xml/serializer/SecuritySupport.java | 144 ++++++
.../xml/serializer/SerializationHandler.java | 145 ++++++
.../java/org/apache/xml/serializer/Serializer.java | 237 ++++++++++
.../apache/xml/serializer/XSLOutputAttributes.java | 236 ++++++++++
11 files changed, 1654 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 827baf22a..b53d14f5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,8 @@
<name>Apache ServiceMix :: Bundles</name>
<modules>
+ <module>bundles-pom</module>
+ <module>xalan-2.7.3</module>
</modules>
</project>
diff --git a/xalan-2.7.3/pom.xml b/xalan-2.7.3/pom.xml
index d2c56f8cc..b36673fd5 100644
--- a/xalan-2.7.3/pom.xml
+++ b/xalan-2.7.3/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>bundles-pom</artifactId>
- <version>15</version>
+ <version>16-SNAPSHOT</version>
<relativePath>../bundles-pom/pom.xml</relativePath>
</parent>
@@ -39,13 +39,13 @@
<connection>scm:git:https://gitbox.apache.org/repos/asf/servicemix-bundles.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/servicemix-bundles.git</developerConnection>
<url>https://gitbox.apache.org/repos/asf?p=servicemix-bundles.git</url>
- <tag>HEAD</tag>
</scm>
<properties>
<pkgGroupId>xalan</pkgGroupId>
<pkgArtifactId>xalan</pkgArtifactId>
- <pkgVersion>2.7.2</pkgVersion>
+ <pkgVersion>2.7.3</pkgVersion>
+
<servicemix.osgi.source.version>2.7.3.2</servicemix.osgi.source.version>
<servicemix.osgi.export>
java_cup*;version=${pkgVersion};-split-package:=merge-first,
org.apache.xalan*;version=${pkgVersion};-split-package:=merge-first,
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
b/xalan-2.7.3/src/main/java/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
index c38a343ae..fc010b69b 100644
---
a/xalan-2.7.3/src/main/java/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
+++
b/xalan-2.7.3/src/main/java/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
@@ -30,6 +30,7 @@ import java.util.Enumeration;
import java.util.Vector;
import javax.xml.transform.Templates;
import javax.xml.parsers.DocumentBuilderFactory;
+
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;
import javax.xml.parsers.ParserConfigurationException;
@@ -44,8 +45,8 @@ import org.apache.xalan.xsltc.TransletException;
import org.apache.xalan.xsltc.dom.DOMAdapter;
import org.apache.xalan.xsltc.dom.KeyIndex;
import org.apache.xalan.xsltc.runtime.output.TransletOutputHandlerFactory;
-import org.apache.xml.dtm.DTMAxisIterator;
import org.apache.xml.serializer.SerializationHandler;
+import org.apache.xml.dtm.DTMAxisIterator;
/**
* @author Jacek Ambroziak
@@ -142,7 +143,7 @@ public abstract class AbstractTranslet implements Translet {
* Push a new parameter frame.
*/
public final void pushParamFrame() {
- paramsStack.add(pframe, new Integer(pbase));
+ paramsStack.add(pframe, Integer.valueOf(pbase));
pbase = ++pframe;
}
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/DOMSerializer.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/DOMSerializer.java
new file mode 100644
index 000000000..655c54b9b
--- /dev/null
+++ b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/DOMSerializer.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xml.serializer;
+
+import java.io.IOException;
+
+import org.w3c.dom.Node;
+
+/**
+ * Interface for a DOM serializer implementation.
+ * <p>
+ * The DOMSerializer is a facet of a serializer and is obtained from the
+ * asDOMSerializer() method of the ({@link Serializer}) interface.
+ * A serializer may or may not support a DOM serializer, if it does not then
the
+ * return value from asDOMSerializer() is null.
+ * <p>
+ * Example:
+ * <pre>
+ * // Create a document to be serialized
+ * org.w3c.dom.Document doc = ...;
+ *
+ * // Create a Serializer that will be used
+ * // to serialize the document
+ * org.apache.xml.serializer.Serializer ser = ...;
+ *
+ * // Set the Writer to write output to, and
+ * // serialize the DOM using that Serializer
+ * java.io.StringWriter sw = new java.io.StringWriter();
+ * ser.setWriter(sw);
+ * DOMSerialzier dser = ser.asDOMSerializer();
+ * dser.serialize(doc);
+ *
+ * // Write out the serialized XML in the String.
+ * System.out.println(sw.toString());
+ * </pre>
+ *
+ * @see OutputPropertiesFactory
+ * @see SerializerFactory
+ * @see Serializer
+ *
+ * @xsl.usage general
+ *
+ */
+public interface DOMSerializer
+{
+ /**
+ * Serializes the DOM node. Throws an exception only if an I/O
+ * exception occured while serializing.
+ *
+ * This interface is a public API.
+ *
+ * @param node the DOM node to serialize
+ * @throws IOException if an I/O exception occured while serializing
+ */
+ public void serialize(Node node) throws IOException;
+}
\ No newline at end of file
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/ExtendedContentHandler.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/ExtendedContentHandler.java
new file mode 100644
index 000000000..8a8a05245
--- /dev/null
+++
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/ExtendedContentHandler.java
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xml.serializer;
+
+import javax.xml.transform.SourceLocator;
+
+import org.xml.sax.SAXException;
+
+/**
+ * This interface describes extensions to the SAX ContentHandler interface.
+ * It is intended to be used by a serializer. The methods on this interface
will
+ * implement SAX- like behavior. This allows the gradual collection of
+ * information rather than having it all up front. For example the call
+ * <pre>
+ * startElement(namespaceURI,localName,qName,atts)
+ * </pre>
+ * could be replaced with the calls
+ * <pre>
+ * startElement(namespaceURI,localName,qName)
+ * addAttributes(atts)
+ * </pre>
+ * If there are no attributes the second call can be dropped. If attributes are
+ * to be added one at a time with calls to
+ * <pre>
+ * addAttribute(namespaceURI, localName, qName, type, value)
+ * </pre>
+ * @xsl.usage internal
+ */
+public interface ExtendedContentHandler extends org.xml.sax.ContentHandler
+{
+ /**
+ * Add at attribute to the current element
+ * @param uri the namespace URI of the attribute name
+ * @param localName the local name of the attribute (without prefix)
+ * @param rawName the qualified name of the attribute
+ * @param type the attribute type typically character data (CDATA)
+ * @param value the value of the attribute
+ * @param XSLAttribute true if the added attribute is coming from an
xsl:attribute element
+ * @throws SAXException
+ */
+ public void addAttribute(
+ String uri,
+ String localName,
+ String rawName,
+ String type,
+ String value,
+ boolean XSLAttribute)
+ throws SAXException;
+ /**
+ * Add attributes to the current element
+ * @param atts the attributes to add.
+ * @throws SAXException
+ */
+ public void addAttributes(org.xml.sax.Attributes atts)
+ throws org.xml.sax.SAXException;
+ /**
+ * Add an attribute to the current element. The namespace URI of the
+ * attribute will be calculated from the prefix of qName. The local name
+ * will be derived from qName and the type will be assumed to be "CDATA".
+ * @param qName
+ * @param value
+ */
+ public void addAttribute(String qName, String value);
+
+ /**
+ * This method is used to notify of a character event, but passing the data
+ * as a character String rather than the standard character array.
+ * @param chars the character data
+ * @throws SAXException
+ */
+ public void characters(String chars) throws SAXException;
+
+ /**
+ * This method is used to notify of a character event, but passing the data
+ * as a DOM Node rather than the standard character array.
+ * @param node a DOM Node containing text.
+ * @throws SAXException
+ */
+ public void characters(org.w3c.dom.Node node) throws
org.xml.sax.SAXException;
+ /**
+ * This method is used to notify that an element has ended. Unlike the
+ * standard SAX method
+ * <pre>
+ * endElement(namespaceURI,localName,qName)
+ * </pre>
+ * only the last parameter is passed. If needed the serializer can derive
+ * the localName from the qualified name and derive the namespaceURI from
+ * its implementation.
+ * @param elemName the fully qualified element name.
+ * @throws SAXException
+ */
+ public void endElement(String elemName) throws SAXException;
+
+ /**
+ * This method is used to notify that an element is starting.
+ * This method is just like the standard SAX method
+ * <pre>
+ * startElement(uri,localName,qname,atts)
+ * </pre>
+ * but without the attributes.
+ * @param uri the namespace URI of the element
+ * @param localName the local name (without prefix) of the element
+ * @param qName the qualified name of the element
+ *
+ * @throws SAXException
+ */
+ public void startElement(String uri, String localName, String qName)
+ throws org.xml.sax.SAXException;
+
+ /**
+ * This method is used to notify of the start of an element
+ * @param qName the fully qualified name of the element
+ * @throws SAXException
+ */
+ public void startElement(String qName) throws SAXException;
+ /**
+ * This method is used to notify that a prefix mapping is to start, but
+ * after an element is started. The SAX method call
+ * <pre>
+ * startPrefixMapping(prefix,uri)
+ * </pre>
+ * is used just before an element starts and applies to the element to
come,
+ * not to the current element. This method applies to the current element.
+ * For example one could make the calls in this order:
+ * <pre>
+ * startElement("prfx8:elem9")
+ * namespaceAfterStartElement("http://namespace8","prfx8")
+ * </pre>
+ *
+ * @param uri the namespace URI being declared
+ * @param prefix the prefix that maps to the given namespace
+ * @throws SAXException
+ */
+ public void namespaceAfterStartElement(String uri, String prefix)
+ throws SAXException;
+
+ /**
+ * This method is used to notify that a prefix maping is to start, which
can
+ * be for the current element, or for the one to come.
+ * @param prefix the prefix that maps to the given URI
+ * @param uri the namespace URI of the given prefix
+ * @param shouldFlush if true this call is like the SAX
+ * startPrefixMapping(prefix,uri) call and the mapping applies to the
+ * element to come. If false the mapping applies to the current element.
+ * @return boolean false if the prefix mapping was already in effect (in
+ * other words we are just re-declaring), true if this is a new, never
+ * before seen mapping for the element.
+ * @throws SAXException
+ */
+ public boolean startPrefixMapping(
+ String prefix,
+ String uri,
+ boolean shouldFlush)
+ throws SAXException;
+ /**
+ * Notify of an entity reference.
+ * @param entityName the name of the entity
+ * @throws SAXException
+ */
+ public void entityReference(String entityName) throws SAXException;
+
+ /**
+ * This method returns an object that has the current namespace mappings in
+ * effect.
+ *
+ * @return NamespaceMappings an object that has the current namespace
+ * mappings in effect.
+ */
+ public NamespaceMappings getNamespaceMappings();
+ /**
+ * This method returns the prefix that currently maps to the given
namespace
+ * URI.
+ * @param uri the namespace URI
+ * @return String the prefix that currently maps to the given URI.
+ */
+ public String getPrefix(String uri);
+ /**
+ * This method gets the prefix associated with a current element or
+ * attribute name.
+ * @param name the qualified name of an element, or attribute
+ * @param isElement true if it is an element name, false if it is an
+ * atttribute name
+ * @return String the namespace URI associated with the element or
+ * attribute.
+ */
+ public String getNamespaceURI(String name, boolean isElement);
+ /**
+ * This method returns the namespace URI currently associated with the
+ * prefix.
+ * @param prefix a prefix of an element or attribute.
+ * @return String the namespace URI currently associated with the prefix.
+ */
+ public String getNamespaceURIFromPrefix(String prefix);
+
+ /**
+ * This method is used to set the source locator, which might be used to
+ * generated an error message.
+ * @param locator the source locator
+ */
+ public void setSourceLocator(SourceLocator locator);
+
+ // Bit constants for addUniqueAttribute().
+
+ // The attribute value contains no bad characters. A "bad" character is
one which
+ // is greater than 126 or it is one of '<', '>', '&' or '"'.
+ public static final int NO_BAD_CHARS = 0x1;
+
+ // An HTML empty attribute (e.g. <OPTION selected>).
+ public static final int HTML_ATTREMPTY = 0x2;
+
+ // An HTML URL attribute
+ public static final int HTML_ATTRURL = 0x4;
+
+ /**
+ * Add a unique attribute to the current element.
+ * The attribute is guaranteed to be unique here. The serializer can write
+ * it out immediately without saving it in a table first. The integer
+ * flag contains information about the attribute, which helps the
serializer
+ * to decide whether a particular processing is needed.
+ *
+ * @param qName the fully qualified attribute name.
+ * @param value the attribute value
+ * @param flags a bitwise flag
+ */
+ public void addUniqueAttribute(String qName, String value, int flags)
+ throws SAXException;
+
+ /**
+ * Add an attribute from an xsl:attribute element.
+ * @param qName the qualified attribute name (prefix:localName)
+ * @param value the attributes value
+ * @param uri the uri that the prefix of the qName is mapped to.
+ */
+ public void addXSLAttribute(String qName, final String value, final String
uri);
+
+ /**
+ * Add at attribute to the current element, not from an xsl:attribute
+ * element.
+ * @param uri the namespace URI of the attribute name
+ * @param localName the local name of the attribute (without prefix)
+ * @param rawName the qualified name of the attribute
+ * @param type the attribute type typically character data (CDATA)
+ * @param value the value of the attribute
+ * @throws SAXException
+ */
+ public void addAttribute(
+ String uri,
+ String localName,
+ String rawName,
+ String type,
+ String value)
+ throws SAXException;
+}
\ No newline at end of file
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/ExtendedLexicalHandler.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/ExtendedLexicalHandler.java
new file mode 100644
index 000000000..047f7837f
--- /dev/null
+++
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/ExtendedLexicalHandler.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xml.serializer;
+
+import org.xml.sax.SAXException;
+
+/**
+ * This interface has extensions to the standard SAX LexicalHandler interface.
+ * This interface is intended to be used by a serializer.
+ * @xsl.usage internal
+ */
+public interface ExtendedLexicalHandler extends org.xml.sax.ext.LexicalHandler
+{
+ /**
+ * This method is used to notify of a comment
+ * @param comment the comment, but unlike the SAX comment() method this
+ * method takes a String rather than a character array.
+ * @throws SAXException
+ */
+ public void comment(String comment) throws SAXException;
+}
\ No newline at end of file
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/NamespaceMappings.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/NamespaceMappings.java
new file mode 100644
index 000000000..83d8ff398
--- /dev/null
+++ b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/NamespaceMappings.java
@@ -0,0 +1,500 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xml.serializer;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * This class keeps track of the currently defined namespaces. Conceptually the
+ * prefix/uri/depth triplets are pushed on a stack pushed on a stack. The depth
+ * indicates the nesting depth of the element for which the mapping was made.
+ *
+ * <p>For example:
+ * <pre>
+ * <chapter xmlns:p1="def">
+ * <paragraph xmlns:p2="ghi">
+ * <sentance xmlns:p3="jkl">
+ * </sentance>
+ * </paragraph>
+ * <paragraph xlmns:p4="mno">
+ * </paragraph>
+ * </chapter>
+ * </pre>
+ *
+ * When the <chapter> element is encounted the prefix "p1" associated with uri
+ * "def" is pushed on the stack with depth 1.
+ * When the first <paragraph> is encountered "p2" and "ghi" are pushed with
+ * depth 2.
+ * When the <sentance> is encountered "p3" and "jkl" are pushed with depth 3.
+ * When </sentance> occurs the popNamespaces(3) will pop "p3"/"jkl" off the
+ * stack. Of course popNamespaces(2) would pop anything with depth 2 or
+ * greater.
+ *
+ * So prefix/uri pairs are pushed and poped off the stack as elements are
+ * processed. At any given moment of processing the currently visible prefixes
+ * are on the stack and a prefix can be found given a uri, or a uri can be
found
+ * given a prefix.
+ *
+ * This class is intended for internal use only. However, it is made public
because
+ * other packages require it.
+ * @xsl.usage internal
+ */
+public class NamespaceMappings
+{
+ /**
+ * This member is continually incremented when new prefixes need to be
+ * generated. ("ns0" "ns1" ...)
+ */
+ private int count = 0;
+
+ /**
+ * Each entry (prefix) in this hashtable points to a Stack of URIs
+ * This table maps a prefix (String) to a Stack of NamespaceNodes.
+ * All Namespace nodes in that retrieved stack have the same prefix,
+ * though possibly different URI's or depths. Such a stack must have
+ * mappings at deeper depths push later on such a stack. Mappings pushed
+ * earlier on the stack will have smaller values for
MappingRecord.m_declarationDepth.
+ */
+ private Hashtable m_namespaces = new Hashtable();
+
+ /**
+ * This stack is used as a convenience.
+ * It contains the pushed NamespaceNodes (shallowest
+ * to deepest) and is used to delete NamespaceNodes
+ * when leaving the current element depth
+ * to returning to the parent. The mappings of the deepest
+ * depth can be popped of the top and the same node
+ * can be removed from the appropriate prefix stack.
+ *
+ * All prefixes pushed at the current depth can be
+ * removed at the same time by using this stack to
+ * ensure prefix/uri map scopes are closed correctly.
+ */
+ private Stack m_nodeStack = new Stack();
+
+ private static final String EMPTYSTRING = "";
+ private static final String XML_PREFIX = "xml"; // was "xmlns"
+
+ /**
+ * Default constructor
+ * @see java.lang.Object#Object()
+ */
+ public NamespaceMappings()
+ {
+ initNamespaces();
+ }
+
+ /**
+ * This method initializes the namespace object with appropriate stacks
+ * and predefines a few prefix/uri pairs which always exist.
+ */
+ private void initNamespaces()
+ {
+ // The initial prefix mappings will never be deleted because they are
at element depth -1
+ // (a kludge)
+
+ // Define the default namespace (initially maps to "" uri)
+ Stack stack;
+ MappingRecord nn;
+ nn = new MappingRecord(EMPTYSTRING, EMPTYSTRING, -1);
+ stack = createPrefixStack(EMPTYSTRING);
+ stack.push(nn);
+
+ // define "xml" namespace
+ nn = new MappingRecord(XML_PREFIX,
"http://www.w3.org/XML/1998/namespace", -1);
+ stack = createPrefixStack(XML_PREFIX);
+ stack.push(nn);
+ }
+
+ /**
+ * Use a namespace prefix to lookup a namespace URI.
+ *
+ * @param prefix String the prefix of the namespace
+ * @return the URI corresponding to the prefix, returns ""
+ * if there is no visible mapping.
+ */
+ public String lookupNamespace(String prefix)
+ {
+ String uri = null;
+ final Stack stack = getPrefixStack(prefix);
+ if (stack != null && !stack.isEmpty()) {
+ uri = ((MappingRecord) stack.peek()).m_uri;
+ }
+ if (uri == null)
+ uri = EMPTYSTRING;
+ return uri;
+ }
+
+
+ MappingRecord getMappingFromPrefix(String prefix) {
+ final Stack stack = (Stack) m_namespaces.get(prefix);
+ return stack != null && !stack.isEmpty() ?
+ ((MappingRecord) stack.peek()) : null;
+ }
+
+ /**
+ * Given a namespace uri, and the namespaces mappings for the
+ * current element, return the current prefix for that uri.
+ *
+ * @param uri the namespace URI to be search for
+ * @return an existing prefix that maps to the given URI, null if no prefix
+ * maps to the given namespace URI.
+ */
+ public String lookupPrefix(String uri)
+ {
+ String foundPrefix = null;
+ Enumeration prefixes = m_namespaces.keys();
+ while (prefixes.hasMoreElements())
+ {
+ String prefix = (String) prefixes.nextElement();
+ String uri2 = lookupNamespace(prefix);
+ if (uri2 != null && uri2.equals(uri))
+ {
+ foundPrefix = prefix;
+ break;
+ }
+ }
+ return foundPrefix;
+ }
+
+ MappingRecord getMappingFromURI(String uri)
+ {
+ MappingRecord foundMap = null;
+ Enumeration prefixes = m_namespaces.keys();
+ while (prefixes.hasMoreElements())
+ {
+ String prefix = (String) prefixes.nextElement();
+ MappingRecord map2 = getMappingFromPrefix(prefix);
+ if (map2 != null && (map2.m_uri).equals(uri))
+ {
+ foundMap = map2;
+ break;
+ }
+ }
+ return foundMap;
+ }
+
+ /**
+ * Undeclare the namespace that is currently pointed to by a given prefix
+ */
+ boolean popNamespace(String prefix)
+ {
+ // Prefixes "xml" and "xmlns" cannot be redefined
+ if (prefix.startsWith(XML_PREFIX))
+ {
+ return false;
+ }
+
+ Stack stack;
+ if ((stack = getPrefixStack(prefix)) != null)
+ {
+ stack.pop();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Declare a mapping of a prefix to namespace URI at the given element
depth.
+ * @param prefix a String with the prefix for a qualified name
+ * @param uri a String with the uri to which the prefix is to map
+ * @param elemDepth the depth of current declaration
+ */
+ public boolean pushNamespace(String prefix, String uri, int elemDepth)
+ {
+ // Prefixes "xml" and "xmlns" cannot be redefined
+ if (prefix.startsWith(XML_PREFIX))
+ {
+ return false;
+ }
+
+ Stack stack;
+ // Get the stack that contains URIs for the specified prefix
+ if ((stack = (Stack) m_namespaces.get(prefix)) == null)
+ {
+ m_namespaces.put(prefix, stack = new Stack());
+ }
+
+ if (!stack.empty())
+ {
+ MappingRecord mr = (MappingRecord)stack.peek();
+ if (uri.equals(mr.m_uri) || elemDepth == mr.m_declarationDepth) {
+ // If the same prefix/uri mapping is already on the stack
+ // don't push this one.
+ // Or if we have a mapping at the same depth
+ // don't replace by pushing this one.
+ return false;
+ }
+ }
+ MappingRecord map = new MappingRecord(prefix,uri,elemDepth);
+ stack.push(map);
+ m_nodeStack.push(map);
+ return true;
+ }
+
+ /**
+ * Pop, or undeclare all namespace definitions that are currently
+ * declared at the given element depth, or deepter.
+ * @param elemDepth the element depth for which mappings declared at this
+ * depth or deeper will no longer be valid
+ * @param saxHandler The ContentHandler to notify of any endPrefixMapping()
+ * calls. This parameter can be null.
+ */
+ void popNamespaces(int elemDepth, ContentHandler saxHandler)
+ {
+ while (true)
+ {
+ if (m_nodeStack.isEmpty())
+ return;
+ MappingRecord map = (MappingRecord) (m_nodeStack.peek());
+ int depth = map.m_declarationDepth;
+ if (elemDepth < 1 || map.m_declarationDepth < elemDepth)
+ break;
+ /* the depth of the declared mapping is elemDepth or deeper
+ * so get rid of it
+ */
+
+ MappingRecord nm1 = (MappingRecord) m_nodeStack.pop();
+ // pop the node from the stack
+ String prefix = map.m_prefix;
+
+ Stack prefixStack = getPrefixStack(prefix);
+ MappingRecord nm2 = (MappingRecord) prefixStack.peek();
+ if (nm1 == nm2)
+ {
+ // It would be nice to always pop() but we
+ // need to check that the prefix stack still has
+ // the node we want to get rid of. This is because
+ // the optimization of essentially this situation:
+ // <a xmlns:x="abc"><b xmlns:x="" xmlns:x="abc" /></a>
+ // will remove both mappings in <b> because the
+ // new mapping is the same as the masked one and we get
+ // <a xmlns:x="abc"><b/></a>
+ // So we are only removing xmlns:x="" or
+ // xmlns:x="abc" from the depth of element <b>
+ // when going back to <a> if in fact they have
+ // not been optimized away.
+ //
+ prefixStack.pop();
+ if (saxHandler != null)
+ {
+ try
+ {
+ saxHandler.endPrefixMapping(prefix);
+ }
+ catch (SAXException e)
+ {
+ // not much we can do if they aren't willing to listen
+ }
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Generate a new namespace prefix ( ns0, ns1 ...) not used before
+ * @return String a new namespace prefix ( ns0, ns1, ns2 ...)
+ */
+ public String generateNextPrefix()
+ {
+ return "ns" + (count++);
+ }
+
+
+ /**
+ * This method makes a clone of this object.
+ *
+ */
+ public Object clone() throws CloneNotSupportedException {
+ NamespaceMappings clone = new NamespaceMappings();
+ clone.m_nodeStack = (NamespaceMappings.Stack) m_nodeStack.clone();
+ clone.count = this.count;
+ clone.m_namespaces = (Hashtable) m_namespaces.clone();
+
+ clone.count = count;
+ return clone;
+
+ }
+
+ final void reset()
+ {
+ this.count = 0;
+ this.m_namespaces.clear();
+ this.m_nodeStack.clear();
+
+ initNamespaces();
+ }
+
+ /**
+ * Just a little class that ties the 3 fields together
+ * into one object, and this simplifies the pushing
+ * and popping of namespaces to one push or one pop on
+ * one stack rather than on 3 separate stacks.
+ */
+ static class MappingRecord {
+ final String m_prefix; // the prefix
+ final String m_uri; // the uri, possibly "" but never null
+ // the depth of the element where declartion was made
+ final int m_declarationDepth;
+ MappingRecord(String prefix, String uri, int depth) {
+ m_prefix = prefix;
+ m_uri = (uri==null)? EMPTYSTRING : uri;
+ m_declarationDepth = depth;
+ }
+ }
+
+ /**
+ * Rather than using java.util.Stack, this private class
+ * provides a minimal subset of methods and is faster
+ * because it is not thread-safe.
+ */
+ private class Stack {
+ private int top = -1;
+ private int max = 20;
+ Object[] m_stack = new Object[max];
+
+ public Object clone() throws CloneNotSupportedException {
+ NamespaceMappings.Stack clone = new NamespaceMappings.Stack();
+ clone.max = this.max;
+ clone.top = this.top;
+ clone.m_stack = new Object[clone.max];
+ for (int i=0; i <= top; i++) {
+ // We are just copying references to immutable MappingRecord
objects here
+ // so it is OK if the clone has references to these.
+ clone.m_stack[i] = this.m_stack[i];
+ }
+ return clone;
+ }
+
+ public Stack()
+ {
+ }
+
+ public Object push(Object o) {
+ top++;
+ if (max <= top) {
+ int newMax = 2*max + 1;
+ Object[] newArray = new Object[newMax];
+ System.arraycopy(m_stack,0, newArray, 0, max);
+ max = newMax;
+ m_stack = newArray;
+ }
+ m_stack[top] = o;
+ return o;
+ }
+
+ public Object pop() {
+ Object o;
+ if (0 <= top) {
+ o = m_stack[top];
+ // m_stack[top] = null; do we really care?
+ top--;
+ }
+ else
+ o = null;
+ return o;
+ }
+
+ public Object peek() {
+ Object o;
+ if (0 <= top) {
+ o = m_stack[top];
+ }
+ else
+ o = null;
+ return o;
+ }
+
+ public Object peek(int idx) {
+ return m_stack[idx];
+ }
+
+ public boolean isEmpty() {
+ return (top < 0);
+ }
+ public boolean empty() {
+ return (top < 0);
+ }
+
+ public void clear() {
+ for (int i=0; i<= top; i++)
+ m_stack[i] = null;
+ top = -1;
+ }
+
+ public Object getElement(int index) {
+ return m_stack[index];
+ }
+ }
+ /**
+ * A more type-safe way to get a stack of prefix mappings
+ * from the Hashtable m_namespaces
+ * (this is the only method that does the type cast).
+ */
+
+ private Stack getPrefixStack(String prefix) {
+ Stack fs = (Stack) m_namespaces.get(prefix);
+ return fs;
+ }
+
+ /**
+ * A more type-safe way of saving stacks under the
+ * m_namespaces Hashtable.
+ */
+ private Stack createPrefixStack(String prefix)
+ {
+ Stack fs = new Stack();
+ m_namespaces.put(prefix, fs);
+ return fs;
+ }
+
+ /**
+ * Given a namespace uri, get all prefixes bound to the Namespace URI in
the current scope.
+ *
+ * @param uri the namespace URI to be search for
+ * @return An array of Strings which are
+ * all prefixes bound to the namespace URI in the current scope.
+ * An array of zero elements is returned if no prefixes map to the given
+ * namespace URI.
+ */
+ public String[] lookupAllPrefixes(String uri)
+ {
+ java.util.ArrayList foundPrefixes = new java.util.ArrayList();
+ Enumeration prefixes = m_namespaces.keys();
+ while (prefixes.hasMoreElements())
+ {
+ String prefix = (String) prefixes.nextElement();
+ String uri2 = lookupNamespace(prefix);
+ if (uri2 != null && uri2.equals(uri))
+ {
+ foundPrefixes.add(prefix);
+ }
+ }
+ String[] prefixArray = new String[foundPrefixes.size()];
+ foundPrefixes.toArray(prefixArray);
+ return prefixArray;
+ }
+}
\ No newline at end of file
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/SecuritySupport.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/SecuritySupport.java
new file mode 100644
index 000000000..ae801a83f
--- /dev/null
+++ b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/SecuritySupport.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+
+package org.apache.xml.serializer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * This class is duplicated for each Xalan-Java subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the Xalan-Java
+ * API.
+ *
+ * Security related methods that only work on J2SE 1.2 and newer.
+ */
+final class SecuritySupport {
+
+ static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl =
Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) { }
+ return cl;
+ }
+ });
+ }
+
+ static ClassLoader getSystemClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = ClassLoader.getSystemClassLoader();
+ } catch (SecurityException ex) {}
+ return cl;
+ }
+ });
+ }
+
+ static ClassLoader getParentClassLoader(final ClassLoader cl) {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader parent = null;
+ try {
+ parent = cl.getParent();
+ } catch (SecurityException ex) {}
+
+ // eliminate loops in case of the boot
+ // ClassLoader returning itself as a parent
+ return (parent == cl) ? null : parent;
+ }
+ });
+ }
+
+ static String getSystemProperty(final String propName) {
+ return (String)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty(propName);
+ }
+ });
+ }
+
+ static FileInputStream getFileInputStream(final File file)
+ throws FileNotFoundException
+ {
+ try {
+ return (FileInputStream)
+ AccessController.doPrivileged(new
PrivilegedExceptionAction() {
+ public Object run() throws FileNotFoundException {
+ return new FileInputStream(file);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (FileNotFoundException)e.getException();
+ }
+ }
+
+ static InputStream getResourceAsStream(final ClassLoader cl,
+ final String name)
+ {
+ return (InputStream)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ InputStream ris;
+ if (cl == null) {
+ ris = ClassLoader.getSystemResourceAsStream(name);
+ } else {
+ ris = cl.getResourceAsStream(name);
+ }
+ return ris;
+ }
+ });
+ }
+
+ static boolean getFileExists(final File f) {
+ return ((Boolean)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return f.exists() ? Boolean.TRUE : Boolean.FALSE;
+ }
+ })).booleanValue();
+ }
+
+ static long getLastModified(final File f) {
+ return ((Long)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Long(f.lastModified());
+ }
+ })).longValue();
+ }
+
+ private SecuritySupport () {}
+}
\ No newline at end of file
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/SerializationHandler.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/SerializationHandler.java
new file mode 100644
index 000000000..3810afadc
--- /dev/null
+++
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/SerializationHandler.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xml.serializer;
+
+import java.io.IOException;
+
+import javax.xml.transform.Transformer;
+
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.DeclHandler;
+
+/**
+ * This interface is the one that a serializer implements. It is a group of
+ * other interfaces, such as ExtendedContentHandler, ExtendedLexicalHandler
etc.
+ * In addition there are other methods, such as reset().
+ *
+ * This class is public only because it is used in another package,
+ * it is not a public API.
+ *
+ * @xsl.usage internal
+ */
+public interface SerializationHandler
+ extends
+ ExtendedContentHandler,
+ ExtendedLexicalHandler,
+ XSLOutputAttributes,
+ DeclHandler,
+ org.xml.sax.DTDHandler,
+ ErrorHandler,
+ DOMSerializer,
+ Serializer
+{
+ /**
+ * Set the SAX Content handler that the serializer sends its output to.
This
+ * method only applies to a ToSAXHandler, not to a ToStream serializer.
+ *
+ * @see Serializer#asContentHandler()
+ * @see ToSAXHandler
+ */
+ public void setContentHandler(ContentHandler ch);
+
+ public void close();
+
+ /**
+ * Notify that the serializer should take this DOM node as input to be
+ * serialized.
+ *
+ * @param node the DOM node to be serialized.
+ * @throws IOException
+ */
+ public void serialize(Node node) throws IOException;
+ /**
+ * Turns special character escaping on/off.
+ *
+ * Note that characters will
+ * never, even if this option is set to 'true', be escaped within
+ * CDATA sections in output XML documents.
+ *
+ * @param escape true if escaping is to be set on.
+ */
+ public boolean setEscaping(boolean escape) throws SAXException;
+
+ /**
+ * Set the number of spaces to indent for each indentation level.
+ * @param spaces the number of spaces to indent for each indentation level.
+ */
+ public void setIndentAmount(int spaces);
+
+ /**
+ * Set the transformer associated with the serializer.
+ * @param transformer the transformer associated with the serializer.
+ */
+ public void setTransformer(Transformer transformer);
+
+ /**
+ * Get the transformer associated with the serializer.
+ * @return Transformer the transformer associated with the serializer.
+ */
+ public Transformer getTransformer();
+
+ /**
+ * Used only by TransformerSnapshotImpl to restore the serialization
+ * to a previous state.
+ *
+ * @param mappings NamespaceMappings
+ */
+ public void setNamespaceMappings(NamespaceMappings mappings);
+
+ /**
+ * A SerializationHandler accepts SAX-like events, so
+ * it can accumulate attributes or namespace nodes after
+ * a startElement().
+ * <p>
+ * If the SerializationHandler has a Writer or OutputStream,
+ * a call to this method will flush such accumulated
+ * events as a closed start tag for an element.
+ * <p>
+ * If the SerializationHandler wraps a ContentHandler,
+ * a call to this method will flush such accumulated
+ * events as a SAX (not SAX-like) calls to
+ * startPrefixMapping() and startElement().
+ * <p>
+ * If one calls endDocument() then one need not call
+ * this method since a call to endDocument() will
+ * do what this method does. However, in some
+ * circumstances, such as with document fragments,
+ * endDocument() is not called and it may be
+ * necessary to call this method to flush
+ * any pending events.
+ * <p>
+ * For performance reasons this method should not be called
+ * very often.
+ */
+ public void flushPending() throws SAXException;
+
+ /**
+ * Default behavior is to expand DTD entities,
+ * that is the initall default value is true.
+ * @param expand true if DTD entities are to be expanded,
+ * false if they are to be left as DTD entity references.
+ */
+ public void setDTDEntityExpansion(boolean expand);
+
+}
\ No newline at end of file
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/Serializer.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/Serializer.java
new file mode 100644
index 000000000..bb1f2fd7d
--- /dev/null
+++ b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/Serializer.java
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xml.serializer;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Properties;
+
+import org.xml.sax.ContentHandler;
+
+/**
+ * The Serializer interface is implemented by a serializer to enable users to:
+ * <ul>
+ * <li>get and set streams or writers
+ * <li>configure the serializer with key/value properties
+ * <li>get an org.xml.sax.ContentHandler or a DOMSerializer to provide input to
+ * </ul>
+ *
+ * <p>
+ * Here is an example using the asContentHandler() method:
+ * <pre>
+ * java.util.Properties props =
+ * OutputPropertiesFactory.getDefaultMethodProperties(Method.TEXT);
+ * Serializer ser = SerializerFactory.getSerializer(props);
+ * java.io.PrintStream ostream = System.out;
+ * ser.setOutputStream(ostream);
+ *
+ * // Provide the SAX input events
+ * ContentHandler handler = ser.asContentHandler();
+ * handler.startDocument();
+ * char[] chars = { 'a', 'b', 'c' };
+ * handler.characters(chars, 0, chars.length);
+ * handler.endDocument();
+ *
+ * ser.reset(); // get ready to use the serializer for another document
+ * // of the same output method (TEXT).
+ * </pre>
+ *
+ * <p>
+ * As an alternate to supplying a series of SAX events as input through the
+ * ContentHandler interface, the input to serialize may be given as a DOM.
+ * <p>
+ * For example:
+ * <pre>
+ * org.w3c.dom.Document inputDoc;
+ * org.apache.xml.serializer.Serializer ser;
+ * java.io.Writer owriter;
+ *
+ * java.util.Properties props =
+ * OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
+ * Serializer ser = SerializerFactory.getSerializer(props);
+ * owriter = ...; // create a writer to serialize the document to
+ * ser.setWriter( owriter );
+ *
+ * inputDoc = ...; // create the DOM document to be serialized
+ * DOMSerializer dser = ser.asDOMSerializer(); // a DOM will be serialized
+ * dser.serialize(inputDoc); // serialize the DOM, sending output to owriter
+ *
+ * ser.reset(); // get ready to use the serializer for another document
+ * // of the same output method.
+ * </pre>
+ *
+ * This interface is a public API.
+ *
+ * @see Method
+ * @see OutputPropertiesFactory
+ * @see SerializerFactory
+ * @see DOMSerializer
+ * @see ContentHandler
+ *
+ * @xsl.usage general
+ */
+public interface Serializer {
+
+ /**
+ * Specifies an output stream to which the document should be
+ * serialized. This method should not be called while the
+ * serializer is in the process of serializing a document.
+ * <p>
+ * The encoding specified in the output {@link Properties} is used, or
+ * if no encoding was specified, the default for the selected
+ * output method.
+ * <p>
+ * Only one of setWriter() or setOutputStream() should be called.
+ *
+ * @param output The output stream
+ */
+ public void setOutputStream(OutputStream output);
+
+ /**
+ * Get the output stream where the events will be serialized to.
+ *
+ * @return reference to the result stream, or null if only a writer was
+ * set.
+ */
+ public OutputStream getOutputStream();
+
+ /**
+ * Specifies a writer to which the document should be serialized.
+ * This method should not be called while the serializer is in
+ * the process of serializing a document.
+ * <p>
+ * The encoding specified for the output {@link Properties} must be
+ * identical to the output format used with the writer.
+ *
+ * <p>
+ * Only one of setWriter() or setOutputStream() should be called.
+ *
+ * @param writer The output writer stream
+ */
+ public void setWriter(Writer writer);
+
+ /**
+ * Get the character stream where the events will be serialized to.
+ *
+ * @return Reference to the result Writer, or null.
+ */
+ public Writer getWriter();
+
+ /**
+ * Specifies an output format for this serializer. It the
+ * serializer has already been associated with an output format,
+ * it will switch to the new format. This method should not be
+ * called while the serializer is in the process of serializing
+ * a document.
+ * <p>
+ * The standard property keys supported are: "method", "version",
"encoding",
+ * "omit-xml-declaration", "standalone", doctype-public",
+ * "doctype-system", "cdata-section-elements", "indent", "media-type".
+ * These property keys and their values are described in the XSLT
recommendation,
+ * see {@link <a href="http://www.w3.org/TR/1999/REC-xslt-19991116"> XSLT
1.0 recommendation</a>}
+ * <p>
+ * The non-standard property keys supported are defined in {@link
OutputPropertiesFactory}.
+ *
+ * <p>
+ * This method can be called multiple times before a document is
serialized. Each
+ * time it is called more, or over-riding property values, can be
specified. One
+ * property value that can not be changed is that of the "method" property
key.
+ * <p>
+ * The value of the "cdata-section-elements" property key is a whitespace
+ * separated list of elements. If the element is in a namespace then
+ * value is passed in this format: {uri}localName
+ * <p>
+ * If the "cdata-section-elements" key is specified on multiple calls
+ * to this method the set of elements specified in the value
+ * is not replaced from one call to the
+ * next, but it is cumulative across the calls.
+ *
+ * @param format The output format to use, as a set of key/value pairs.
+ */
+ public void setOutputFormat(Properties format);
+
+ /**
+ * Returns the output format properties for this serializer.
+ *
+ * @return The output format key/value pairs in use.
+ */
+ public Properties getOutputFormat();
+
+ /**
+ * Return a {@link ContentHandler} interface to provide SAX input to.
+ * Through the returned object the document to be serailized,
+ * as a series of SAX events, can be provided to the serialzier.
+ * If the serializer does not support the {@link ContentHandler}
+ * interface, it will return null.
+ * <p>
+ * In principle only one of asDOMSerializer() or asContentHander()
+ * should be called.
+ *
+ * @return A {@link ContentHandler} interface into this serializer,
+ * or null if the serializer is not SAX 2 capable
+ * @throws IOException An I/O exception occured
+ */
+ public ContentHandler asContentHandler() throws IOException;
+
+ /**
+ * Return a {@link DOMSerializer} interface into this serializer.
+ * Through the returned object the document to be serialized,
+ * a DOM, can be provided to the serializer.
+ * If the serializer does not support the {@link DOMSerializer}
+ * interface, it should return null.
+ * <p>
+ * In principle only one of asDOMSerializer() or asContentHander()
+ * should be called.
+ *
+ * @return A {@link DOMSerializer} interface into this serializer,
+ * or null if the serializer is not DOM capable
+ * @throws IOException An I/O exception occured
+ */
+ public DOMSerializer asDOMSerializer() throws IOException;
+
+ /**
+ * This method resets the serializer.
+ * If this method returns true, the
+ * serializer may be used for subsequent serialization of new
+ * documents. It is possible to change the output format and
+ * output stream prior to serializing, or to reuse the existing
+ * output format and output stream or writer.
+ *
+ * @return True if serializer has been reset and can be reused
+ */
+ public boolean reset();
+
+ /**
+ * Return an Object into this serializer to be cast to a DOM3Serializer.
+ * Through the returned object the document to be serialized,
+ * a DOM (Level 3), can be provided to the serializer.
+ * If the serializer does not support casting to a {@link DOM3Serializer}
+ * interface, it should return null.
+ * <p>
+ * In principle only one of asDOM3Serializer() or asContentHander()
+ * should be called.
+ *
+ * @return An Object to be cast to a DOM3Serializer interface into this
serializer,
+ * or null if the serializer is not DOM capable
+ * @throws IOException An I/O exception occured
+ */
+ public Object asDOM3Serializer() throws IOException;
+}
diff --git
a/xalan-2.7.3/src/main/java/org/apache/xml/serializer/XSLOutputAttributes.java
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/XSLOutputAttributes.java
new file mode 100644
index 000000000..6ef42e7f4
--- /dev/null
+++
b/xalan-2.7.3/src/main/java/org/apache/xml/serializer/XSLOutputAttributes.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * $Id$
+ */
+package org.apache.xml.serializer;
+
+import java.util.Vector;
+
+/**
+ * This interface has methods associated with the XSLT xsl:output attribues
+ * specified in the stylesheet that effect the format of the document output.
+ *
+ * In an XSLT stylesheet these attributes appear for example as:
+ * <pre>
+ * <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
+ * </pre>
+ * The xsl:output attributes covered in this interface are:
+ * <pre>
+ * version
+ * encoding
+ * omit-xml-declarations
+ * standalone
+ * doctype-public
+ * doctype-system
+ * cdata-section-elements
+ * indent
+ * media-type
+ * </pre>
+ *
+ * The one attribute not covered in this interface is <code>method</code> as
+ * this value is implicitly chosen by the serializer that is created, for
+ * example ToXMLStream vs. ToHTMLStream or another one.
+ *
+ * This interface is only used internally within Xalan.
+ *
+ * @xsl.usage internal
+ */
+interface XSLOutputAttributes
+{
+ /**
+ * Returns the previously set value of the value to be used as the public
+ * identifier in the document type declaration (DTD).
+ *
+ *@return the public identifier to be used in the DOCTYPE declaration in
the
+ * output document.
+ */
+ public String getDoctypePublic();
+ /**
+ * Returns the previously set value of the value to be used
+ * as the system identifier in the document type declaration (DTD).
+ * @return the system identifier to be used in the DOCTYPE declaration in
+ * the output document.
+ *
+ */
+ public String getDoctypeSystem();
+ /**
+ * @return the character encoding to be used in the output document.
+ */
+ public String getEncoding();
+ /**
+ * @return true if the output document should be indented to visually
+ * indicate its structure.
+ */
+ public boolean getIndent();
+
+ /**
+ * @return the number of spaces to indent for each indentation level.
+ */
+ public int getIndentAmount();
+ /**
+ * @return the mediatype the media-type or MIME type associated with the
+ * output document.
+ */
+ public String getMediaType();
+ /**
+ * @return true if the XML declaration is to be omitted from the output
+ * document.
+ */
+ public boolean getOmitXMLDeclaration();
+ /**
+ * @return a value of "yes" if the <code>standalone</code> delaration is to
+ * be included in the output document.
+ */
+ public String getStandalone();
+ /**
+ * @return the version of the output format.
+ */
+ public String getVersion();
+
+
+
+
+
+
+ /**
+ * Sets the value coming from the xsl:output cdata-section-elements
+ * stylesheet property.
+ *
+ * This sets the elements whose text elements are to be output as CDATA
+ * sections.
+ * @param URI_and_localNames pairs of namespace URI and local names that
+ * identify elements whose text elements are to be output as CDATA
sections.
+ * The namespace of the local element must be the given URI to match. The
+ * qName is not given because the prefix does not matter, only the
namespace
+ * URI to which that prefix would map matters, so the prefix itself is not
+ * relevant in specifying which elements have their text to be output as
+ * CDATA sections.
+ */
+ public void setCdataSectionElements(Vector URI_and_localNames);
+
+ /** Set the value coming from the xsl:output doctype-public and
doctype-system stylesheet properties
+ * @param system the system identifier to be used in the DOCTYPE
declaration
+ * in the output document.
+ * @param pub the public identifier to be used in the DOCTYPE declaration
in
+ * the output document.
+ */
+ public void setDoctype(String system, String pub);
+
+ /** Set the value coming from the xsl:output doctype-public stylesheet
attribute.
+ * @param doctype the public identifier to be used in the DOCTYPE
+ * declaration in the output document.
+ */
+ public void setDoctypePublic(String doctype);
+ /** Set the value coming from the xsl:output doctype-system stylesheet
attribute.
+ * @param doctype the system identifier to be used in the DOCTYPE
+ * declaration in the output document.
+ */
+ public void setDoctypeSystem(String doctype);
+ /**
+ * Sets the character encoding coming from the xsl:output encoding
stylesheet attribute.
+ * @param encoding the character encoding
+ */
+ public void setEncoding(String encoding);
+ /**
+ * Sets the value coming from the xsl:output indent stylesheet
+ * attribute.
+ * @param indent true if the output document should be indented to visually
+ * indicate its structure.
+ */
+ public void setIndent(boolean indent);
+ /**
+ * Sets the value coming from the xsl:output media-type stylesheet
attribute.
+ * @param mediatype the media-type or MIME type associated with the output
+ * document.
+ */
+ public void setMediaType(String mediatype);
+ /**
+ * Sets the value coming from the xsl:output omit-xml-declaration
stylesheet attribute
+ * @param b true if the XML declaration is to be omitted from the output
+ * document.
+ */
+ public void setOmitXMLDeclaration(boolean b);
+ /**
+ * Sets the value coming from the xsl:output standalone stylesheet
attribute.
+ * @param standalone a value of "yes" indicates that the
+ * <code>standalone</code> delaration is to be included in the output
+ * document.
+ */
+ public void setStandalone(String standalone);
+ /**
+ * Sets the value coming from the xsl:output version attribute.
+ * @param version the version of the output format.
+ */
+ public void setVersion(String version);
+
+ /**
+ * Get the value for a property that affects seraialization,
+ * if a property was set return that value, otherwise return
+ * the default value, otherwise return null.
+ * @param name The name of the property, which is just the local name
+ * if it is in no namespace, but is the URI in curly braces followed by
+ * the local name if it is in a namespace, for example:
+ * <ul>
+ * <li> "encoding"
+ * <li> "method"
+ * <li> "{http://xml.apache.org/xalan}indent-amount"
+ * <li> "{http://xml.apache.org/xalan}line-separator"
+ * </ul>
+ * @return The value of the parameter
+ */
+ public String getOutputProperty(String name);
+ /**
+ * Get the default value for a property that affects seraialization,
+ * or null if there is none. It is possible that a non-default value
+ * was set for the property, however the value returned by this method
+ * is unaffected by any non-default settings.
+ * @param name The name of the property.
+ * @return The default value of the parameter, or null if there is no
default value.
+ */
+ public String getOutputPropertyDefault(String name);
+ /**
+ * Set the non-default value for a property that affects seraialization.
+ * @param name The name of the property, which is just the local name
+ * if it is in no namespace, but is the URI in curly braces followed by
+ * the local name if it is in a namespace, for example:
+ * <ul>
+ * <li> "encoding"
+ * <li> "method"
+ * <li> "{http://xml.apache.org/xalan}indent-amount"
+ * <li> "{http://xml.apache.org/xalan}line-separator"
+ * </ul>
+ * @val The non-default value of the parameter
+ */
+ public void setOutputProperty(String name, String val);
+
+ /**
+ * Set the default value for a property that affects seraialization.
+ * @param name The name of the property, which is just the local name
+ * if it is in no namespace, but is the URI in curly braces followed by
+ * the local name if it is in a namespace, for example:
+ * <ul>
+ * <li> "encoding"
+ * <li> "method"
+ * <li> "{http://xml.apache.org/xalan}indent-amount"
+ * <li> "{http://xml.apache.org/xalan}line-separator"
+ * </ul>
+ * @val The default value of the parameter
+ */
+ public void setOutputPropertyDefault(String name, String val);
+}
\ No newline at end of file