< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/TreeWalker.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* 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.
@@ -15,25 +15,23 @@
* 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.
*/
-package com.sun.org.apache.xml.internal.serializer;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-import java.io.File;
+package com.sun.org.apache.xml.internal.serializer;
-import com.sun.org.apache.xml.internal.serializer.utils.AttList;
-import com.sun.org.apache.xml.internal.serializer.utils.DOM2Helper;
+import com.sun.org.apache.xml.internal.utils.AttList;
+import com.sun.org.apache.xml.internal.utils.DOM2Helper;
+import javax.xml.transform.Result;
import org.w3c.dom.Comment;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
-
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.LocatorImpl;
@@ -56,16 +54,10 @@
* If m_contentHandler is a SerializationHandler, then this is
* a reference to the same object.
*/
final private SerializationHandler m_Serializer;
- // ARGHH!! JAXP Uses Xerces without setting the namespace processing to ON!
- // DOM2Helper m_dh = new DOM2Helper();
-
- /** DomHelper for this TreeWalker */
- final protected DOM2Helper m_dh;
-
/** Locator object for this TreeWalker */
final private LocatorImpl m_locator = new LocatorImpl();
/**
* Get the ContentHandler used for the tree walk.
@@ -76,11 +68,11 @@
{
return m_contentHandler;
}
public TreeWalker(ContentHandler ch) {
- this(ch,null);
+ this(ch, null);
}
/**
* Constructor.
* @param contentHandler The implemention of the
* contentHandler operation (toXMLString, digest, ...)
@@ -97,12 +89,10 @@
// Set the system ID, if it is given
m_contentHandler.setDocumentLocator(m_locator);
if (systemId != null) {
m_locator.setSystemId(systemId);
}
-
- m_dh = new DOM2Helper();
}
/**
* Perform a pre-order traversal non-recursive style.
*
@@ -207,11 +197,11 @@
pos = nextNode;
}
this.m_contentHandler.endDocument();
}
- /** Flag indicating whether following text to be processed is raw text */
+ // Flag indicating whether following text to be processed is raw text
boolean nextIsRaw = false;
/**
* Optimized dispatch of characters.
*/
@@ -311,11 +301,10 @@
final Node attr = atts.item(i);
final String attrName = attr.getNodeName();
final int colon = attrName.indexOf(':');
final String prefix;
- // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue());
if (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
{
// Use "" instead of null, as Xerces likes "" for the
// name of the default namespace. Fix attributed
// to "Steven Murray" <smurray@ebt.com>.
@@ -333,17 +322,17 @@
if (uri != null)
this.m_contentHandler.startPrefixMapping(prefix,uri);
}
}
- String ns = m_dh.getNamespaceOfNode(node);
+ String ns = DOM2Helper.getNamespaceOfNode(node);
if(null == ns)
ns = "";
this.m_contentHandler.startElement(ns,
- m_dh.getLocalNameOfNode(node),
+ DOM2Helper.getLocalNameOfNode(node),
node.getNodeName(),
- new AttList(atts, m_dh));
+ new AttList(atts));
break;
case Node.PROCESSING_INSTRUCTION_NODE :
{
ProcessingInstruction pi = (ProcessingInstruction) node;
String name = pi.getNodeName();
@@ -387,13 +376,13 @@
if (nextIsRaw)
{
nextIsRaw = false;
- m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
+ m_contentHandler.processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");
dispatachChars(node);
- m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
+ m_contentHandler.processingInstruction(Result.PI_ENABLE_OUTPUT_ESCAPING, "");
}
else
{
dispatachChars(node);
}
@@ -434,15 +423,15 @@
{
case Node.DOCUMENT_NODE :
break;
case Node.ELEMENT_NODE :
- String ns = m_dh.getNamespaceOfNode(node);
+ String ns = DOM2Helper.getNamespaceOfNode(node);
if(null == ns)
ns = "";
this.m_contentHandler.endElement(ns,
- m_dh.getLocalNameOfNode(node),
+ DOM2Helper.getLocalNameOfNode(node),
node.getNodeName());
if (m_Serializer == null) {
// Don't bother with endPrefixMapping calls if the ContentHandler is a
// SerializationHandler because SerializationHandler's ignore the
< prev index next >