[jboss-svn-commits] JBoss Common SVN: r1937 - tags/JBossCommon-1.0.1/src/main/org/jboss/util/xml
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 10 13:06:34 EDT 2006
Author: thomas.diesler at jboss.com
Date: 2006-08-10 13:06:33 -0400 (Thu, 10 Aug 2006)
New Revision: 1937
Modified:
tags/JBossCommon-1.0.1/src/main/org/jboss/util/xml/DOMWriter.java
Log:
restore tagged version
Modified: tags/JBossCommon-1.0.1/src/main/org/jboss/util/xml/DOMWriter.java
===================================================================
--- tags/JBossCommon-1.0.1/src/main/org/jboss/util/xml/DOMWriter.java 2006-08-10 17:02:47 UTC (rev 1936)
+++ tags/JBossCommon-1.0.1/src/main/org/jboss/util/xml/DOMWriter.java 2006-08-10 17:06:33 UTC (rev 1937)
@@ -65,7 +65,6 @@
import java.io.Writer;
import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -75,6 +74,7 @@
*
* @author Andy Clark, IBM
* @author Thomas.Diesler at jboss.org
+ * @version $Revision$
*/
public class DOMWriter
{
@@ -92,9 +92,7 @@
private int prettyIndent;
// True, if the XML declaration has been written
private boolean wroteXMLDeclaration;
- // The node that started the write
- private Node rootNode;
-
+
public DOMWriter(Writer w)
{
this.out = new PrintWriter(w);
@@ -185,7 +183,6 @@
public void print(Node node)
{
- rootNode = node;
printInternal(node, false);
}
@@ -213,7 +210,6 @@
int type = node.getNodeType();
boolean hasChildNodes = node.getChildNodes().getLength() > 0;
- String nodeName = node.getNodeName();
switch (type)
{
// print document
@@ -228,10 +224,9 @@
break;
}
- // print element with attributes
+ // print element with attributes
case Node.ELEMENT_NODE:
{
- Element element = (Element)node;
if (prettyprint)
{
for (int i = 0; i < prettyIndent; i++)
@@ -242,30 +237,17 @@
}
out.print('<');
- out.print(nodeName);
-
- String prefix = node.getPrefix();
- String nsURI = (prefix != null ? getNamespaceURI(prefix, element, rootNode) : null);
-
+ out.print(node.getNodeName());
Attr attrs[] = sortAttributes(node.getAttributes());
for (int i = 0; i < attrs.length; i++)
{
Attr attr = attrs[i];
- String attrName = attr.getNodeName();
- String attrValue = normalize(attr.getNodeValue());
-
- if (prefix != null && attrName.equals("xmlns:" + prefix))
- nsURI = attrValue;
-
- out.print(" " + attrName + "='" + attrValue + "'");
+ out.print(' ');
+ out.print(attr.getNodeName());
+ out.print("='");
+ out.print(normalize(attr.getNodeValue()));
+ out.print("'");
}
-
- // Add missing namespace declaration
- if (prefix != null && nsURI == null)
- {
- nsURI = getNamespaceURI(prefix, element, null);
- out.print(" xmlns:" + prefix + "='" + nsURI + "'");
- }
if (hasChildNodes)
{
@@ -308,7 +290,7 @@
else
{
out.print('&');
- out.print(nodeName);
+ out.print(node.getNodeName());
out.print(';');
}
break;
@@ -343,7 +325,7 @@
case Node.PROCESSING_INSTRUCTION_NODE:
{
out.print("<?");
- out.print(nodeName);
+ out.print(node.getNodeName());
String data = node.getNodeValue();
if (data != null && data.length() > 0)
{
@@ -399,7 +381,7 @@
}
out.print("</");
- out.print(nodeName);
+ out.print(node.getNodeName());
out.print('>');
}
@@ -411,16 +393,6 @@
out.flush();
}
- private String getNamespaceURI(String prefix, Element element, Node stopNode)
- {
- Node parent = element.getParentNode();
- String nsURI = element.getAttribute("xmlns:" + prefix);
- if (nsURI.length() == 0 && element != stopNode && parent instanceof Element)
- return getNamespaceURI(prefix, (Element)parent, stopNode);
-
- return (nsURI.length() > 0 ? nsURI : null);
- }
-
private boolean isEndMarkerIndented(Node node)
{
if (prettyprint)
More information about the jboss-svn-commits
mailing list