1 16 19 20 package org.apache.xalan.lib; 21 22 import javax.xml.transform.SourceLocator ; 23 24 import org.apache.xalan.extensions.ExpressionContext; 25 import org.apache.xml.dtm.ref.DTMNodeProxy; 26 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.NodeList ; 29 30 37 public class NodeInfo 38 { 39 46 public static String systemId(ExpressionContext context) 47 { 48 Node contextNode = context.getContextNode(); 49 int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); 50 SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() 51 .getSourceLocatorFor(nodeHandler); 52 53 if (locator != null) 54 return locator.getSystemId(); 55 else 56 return null; 57 } 58 59 68 public static String systemId(NodeList nodeList) 69 { 70 if (nodeList == null || nodeList.getLength() == 0) 71 return null; 72 73 Node node = nodeList.item(0); 74 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 75 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 76 .getSourceLocatorFor(nodeHandler); 77 78 if (locator != null) 79 return locator.getSystemId(); 80 else 81 return null; 82 } 83 84 93 public static String publicId(ExpressionContext context) 94 { 95 Node contextNode = context.getContextNode(); 96 int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); 97 SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() 98 .getSourceLocatorFor(nodeHandler); 99 100 if (locator != null) 101 return locator.getPublicId(); 102 else 103 return null; 104 } 105 106 116 public static String publicId(NodeList nodeList) 117 { 118 if (nodeList == null || nodeList.getLength() == 0) 119 return null; 120 121 Node node = nodeList.item(0); 122 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 123 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 124 .getSourceLocatorFor(nodeHandler); 125 126 if (locator != null) 127 return locator.getPublicId(); 128 else 129 return null; 130 } 131 132 146 public static int lineNumber(ExpressionContext context) 147 { 148 Node contextNode = context.getContextNode(); 149 int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); 150 SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() 151 .getSourceLocatorFor(nodeHandler); 152 153 if (locator != null) 154 return locator.getLineNumber(); 155 else 156 return -1; 157 } 158 159 174 public static int lineNumber(NodeList nodeList) 175 { 176 if (nodeList == null || nodeList.getLength() == 0) 177 return -1; 178 179 Node node = nodeList.item(0); 180 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 181 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 182 .getSourceLocatorFor(nodeHandler); 183 184 if (locator != null) 185 return locator.getLineNumber(); 186 else 187 return -1; 188 } 189 190 204 public static int columnNumber(ExpressionContext context) 205 { 206 Node contextNode = context.getContextNode(); 207 int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); 208 SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() 209 .getSourceLocatorFor(nodeHandler); 210 211 if (locator != null) 212 return locator.getColumnNumber(); 213 else 214 return -1; 215 } 216 217 232 public static int columnNumber(NodeList nodeList) 233 { 234 if (nodeList == null || nodeList.getLength() == 0) 235 return -1; 236 237 Node node = nodeList.item(0); 238 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 239 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 240 .getSourceLocatorFor(nodeHandler); 241 242 if (locator != null) 243 return locator.getColumnNumber(); 244 else 245 return -1; 246 } 247 } 248 | Popular Tags |