1 16 19 package org.apache.xalan.trace; 20 21 import org.apache.xalan.templates.ElemTemplateElement; 22 import org.apache.xalan.transformer.TransformerImpl; 23 import org.apache.xml.utils.QName; 24 25 import org.w3c.dom.Attr ; 26 import org.w3c.dom.Element ; 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.NodeList ; 29 30 35 public class TracerEvent implements java.util.EventListener 36 { 37 38 41 public final ElemTemplateElement m_styleNode; 42 43 46 public final TransformerImpl m_processor; 47 48 51 public final Node m_sourceNode; 52 53 56 public final QName m_mode; 57 58 67 public TracerEvent(TransformerImpl processor, Node sourceNode, QName mode, 68 ElemTemplateElement styleNode) 69 { 70 71 this.m_processor = processor; 72 this.m_sourceNode = sourceNode; 73 this.m_mode = mode; 74 this.m_styleNode = styleNode; 75 } 76 77 87 public static String printNode(Node n) 88 { 89 90 String r = n.hashCode() + " "; 91 92 if (n instanceof Element) 93 { 94 r += "<" + n.getNodeName(); 95 96 Node c = n.getFirstChild(); 97 98 while (null != c) 99 { 100 if (c instanceof Attr ) 101 { 102 r += printNode(c) + " "; 103 } 104 105 c = c.getNextSibling(); 106 } 107 108 r += ">"; 109 } 110 else 111 { 112 if (n instanceof Attr ) 113 { 114 r += n.getNodeName() + "=" + n.getNodeValue(); 115 } 116 else 117 { 118 r += n.getNodeName(); 119 } 120 } 121 122 return r; 123 } 124 125 136 public static String printNodeList(NodeList l) 137 { 138 139 String r = l.hashCode() + "["; 140 int len = l.getLength() - 1; 141 int i = 0; 142 143 while (i < len) 144 { 145 Node n = l.item(i); 146 147 if (null != n) 148 { 149 r += printNode(n) + ", "; 150 } 151 152 ++i; 153 } 154 155 if (i == len) 156 { 157 Node n = l.item(len); 158 159 if (null != n) 160 { 161 r += printNode(n); 162 } 163 } 164 165 return r + "]"; 166 } 167 } 168 | Popular Tags |