You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/05/07 21:06:39 UTC
svn commit: r1742751 - in
/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer:
ExtendedContentHandler.java NamespaceMappings.java
SerializationHandler.java SerializerBase.java ToStream.java ToXMLStream.java
Author: veithen
Date: Sat May 7 21:06:39 2016
New Revision: 1742751
URL: http://svn.apache.org/viewvc?rev=1742751&view=rev
Log:
No need to track the namespace context in the serializer.
Removed:
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/NamespaceMappings.java
Modified:
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ExtendedContentHandler.java
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializationHandler.java
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializerBase.java
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToXMLStream.java
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ExtendedContentHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ExtendedContentHandler.java?rev=1742751&r1=1742750&r2=1742751&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ExtendedContentHandler.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ExtendedContentHandler.java Sat May 7 21:06:39 2016
@@ -126,39 +126,6 @@ public interface ExtendedContentHandler
public void entityReference(String entityName) throws StreamException;
/**
- * 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
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializationHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializationHandler.java?rev=1742751&r1=1742750&r2=1742751&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializationHandler.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializationHandler.java Sat May 7 21:06:39 2016
@@ -74,14 +74,6 @@ public interface SerializationHandler
*/
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
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializerBase.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializerBase.java?rev=1742751&r1=1742750&r2=1742751&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializerBase.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/SerializerBase.java Sat May 7 21:06:39 2016
@@ -29,8 +29,6 @@ import javax.xml.transform.SourceLocator
import javax.xml.transform.Transformer;
import org.apache.axiom.core.stream.StreamException;
-import org.apache.axiom.core.stream.serializer.utils.MsgKey;
-import org.apache.axiom.core.stream.serializer.utils.Utils;
import org.xml.sax.Locator;
/**
@@ -151,13 +149,6 @@ public abstract class SerializerBase
*/
private Transformer m_transformer;
- /**
- * Namespace support, that keeps track of currently defined
- * prefix/uri mappings. As processed elements come and go, so do
- * the associated mappings for that element.
- */
- protected NamespaceMappings m_prefixMap;
-
protected SourceLocator m_sourceLocator;
@@ -211,39 +202,6 @@ public abstract class SerializerBase
}
/**
- * If at runtime, when the qname of the attribute is
- * known, another prefix is specified for the attribute, then we can
- * patch or hack the name with this method. For
- * a qname of the form "ns?:otherprefix:name", this function patches the
- * qname by simply ignoring "otherprefix".
- * TODO: This method is a HACK! We do not have access to the
- * XML file, it sometimes generates a NS prefix of the form "ns?" for
- * an attribute.
- */
- protected String patchName(String qname)
- {
-
-
- final int lastColon = qname.lastIndexOf(':');
-
- if (lastColon > 0) {
- final int firstColon = qname.indexOf(':');
- final String prefix = qname.substring(0, firstColon);
- final String localName = qname.substring(lastColon + 1);
-
- // If uri is "" then ignore prefix
- final String uri = m_prefixMap.lookupNamespace(prefix);
- if (uri != null && uri.length() == 0) {
- return localName;
- }
- else if (firstColon != lastColon) {
- return prefix + ':' + localName;
- }
- }
- return qname;
- }
-
- /**
* Returns the local name of a qualified name. If the name has no prefix,
* then it works as the identity (SAX2).
* @param qname the qualified name
@@ -579,74 +537,6 @@ public abstract class SerializerBase
}
/**
- * Some users of the serializer may need the current namespace mappings
- * @return the current namespace mappings (prefix/uri)
- * @see ExtendedContentHandler#getNamespaceMappings()
- */
- public NamespaceMappings getNamespaceMappings()
- {
- return m_prefixMap;
- }
-
- /**
- * Returns the prefix currently pointing to the given URI (if any).
- * @param namespaceURI the uri of the namespace in question
- * @return a prefix pointing to the given URI (if any).
- * @see ExtendedContentHandler#getPrefix(String)
- */
- public String getPrefix(String namespaceURI)
- {
- String prefix = m_prefixMap.lookupPrefix(namespaceURI);
- return prefix;
- }
-
- /**
- * Returns the URI of an element or attribute. Note that default namespaces
- * do not apply directly to attributes.
- * @param qname a qualified name
- * @param isElement true if the qualified name is the name of
- * an element.
- * @return returns the namespace URI associated with the qualified name.
- */
- public String getNamespaceURI(String qname, boolean isElement)
- {
- String uri = EMPTYSTRING;
- int col = qname.lastIndexOf(':');
- final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;
-
- if (!EMPTYSTRING.equals(prefix) || isElement)
- {
- if (m_prefixMap != null)
- {
- uri = m_prefixMap.lookupNamespace(prefix);
- if (uri == null && !prefix.equals(XMLNS_PREFIX))
- {
- throw new RuntimeException(
- Utils.messages.createMessage(
- MsgKey.ER_NAMESPACE_PREFIX,
- new Object[] { qname.substring(0, col) } ));
- }
- }
- }
- return uri;
- }
-
- /**
- * Returns the URI of prefix (if any)
- *
- * @param prefix the prefix whose URI is searched for
- * @return the namespace URI currently associated with the
- * prefix, null if the prefix is undefined.
- */
- public String getNamespaceURIFromPrefix(String prefix)
- {
- String uri = null;
- if (m_prefixMap != null)
- uri = m_prefixMap.lookupNamespace(prefix);
- return uri;
- }
-
- /**
* Entity reference event.
*
* @param name Name of entity
@@ -797,16 +687,6 @@ public abstract class SerializerBase
}
- /**
- * Used only by TransformerSnapshotImpl to restore the serialization
- * to a previous state.
- *
- * @param mappings NamespaceMappings
- */
- public void setNamespaceMappings(NamespaceMappings mappings) {
- m_prefixMap = mappings;
- }
-
public boolean reset()
{
resetSerializerBase();
@@ -834,8 +714,6 @@ public abstract class SerializerBase
this.m_OutputProps.clear();
if (m_OutputPropsDefault != null)
this.m_OutputPropsDefault.clear();
- if (this.m_prefixMap != null)
- this.m_prefixMap.reset();
this.m_shouldNotWriteXMLHeader = false;
this.m_sourceLocator = null;
this.m_standalone = null;
@@ -910,41 +788,6 @@ public abstract class SerializerBase
}
/**
- * Before this call m_elementContext.m_elementURI is null,
- * which means it is not yet known. After this call it
- * is non-null, but possibly "" meaning that it is in the
- * default namespace.
- *
- * @return The URI of the element, never null, but possibly "".
- */
- private String getElementURI() {
- String uri = null;
- // At this point in processing we have received all the
- // namespace mappings
- // As we still don't know the elements namespace,
- // we now figure it out.
-
- String prefix = getPrefixPart(m_elemContext.m_elementName);
-
- if (prefix == null) {
- // no prefix so lookup the URI of the default namespace
- uri = m_prefixMap.lookupNamespace("");
- } else {
- uri = m_prefixMap.lookupNamespace(prefix);
- }
- if (uri == null) {
- // We didn't find the namespace for the
- // prefix ... ouch, that shouldn't happen.
- // This is a hack, we really don't know
- // the namespace
- uri = EMPTYSTRING;
- }
-
- return uri;
- }
-
-
- /**
* Get the value of an output property,
* the explicit value, if any, otherwise the
* default value, if any, otherwise null.
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java?rev=1742751&r1=1742750&r2=1742751&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java Sat May 7 21:06:39 2016
@@ -2035,10 +2035,6 @@ abstract public class ToStream extends S
if (m_inEntityRef)
return;
- // namespaces declared at the current depth are no longer valid
- // so get rid of them
- m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth);
-
try
{
final java.io.Writer writer = m_writer;
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToXMLStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToXMLStream.java?rev=1742751&r1=1742750&r2=1742751&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToXMLStream.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToXMLStream.java Sat May 7 21:06:39 2016
@@ -58,9 +58,6 @@ public class ToXMLStream extends ToStrea
m_charInfo = m_xmlcharInfo;
initCDATA();
- // initialize namespaces
- m_prefixMap = new NamespaceMappings();
-
}
/**