package jas2.util.xml;
import jas2.util.ColorConverter;
import org.w3c.dom.*;
import java.awt.Color;
/**
* Utility class for traversing XML DOM trees
*/
public abstract class XMLNodeTraverser
{
public void traverse(Node node) throws BadXMLException
{
if (node instanceof Element)
{
handleElementAttributes((Element) node);
}
for (Node n = node.getFirstChild(); n != null; n = n.getNextSibling())
{
handleSubNode(n,n.getNodeName());
}
}
protected void handleSubNode(Node node, String name) throws BadXMLException
{
int type = node.getNodeType();
switch (type)
{
case Node.ELEMENT_NODE:
handleElement((Element) node,name);
break;
case Node.TEXT_NODE:
handleTextNode((Text) node,name);
break;
default:
handleOtherNode(node,name);
}
}
protected void handleElementAttributes(Element node) throws BadXMLException
{
NamedNodeMap nnm = node.getAttributes();
for (int i=0; i
Ads help maintain this website.