1 16 19 20 package com.sun.org.apache.xalan.internal.lib; 21 22 import javax.xml.transform.SourceLocator ; 23 24 import com.sun.org.apache.xalan.internal.extensions.ExpressionContext; 25 import com.sun.org.apache.xml.internal.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 67 public static String systemId(NodeList nodeList) 68 { 69 if (nodeList == null || nodeList.getLength() == 0) 70 return null; 71 72 Node node = nodeList.item(0); 73 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 74 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 75 .getSourceLocatorFor(nodeHandler); 76 77 if (locator != null) 78 return locator.getSystemId(); 79 else 80 return null; 81 } 82 83 92 public static String publicId(ExpressionContext context) 93 { 94 Node contextNode = context.getContextNode(); 95 int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); 96 SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() 97 .getSourceLocatorFor(nodeHandler); 98 99 if (locator != null) 100 return locator.getPublicId(); 101 else 102 return null; 103 } 104 105 115 public static String publicId(NodeList nodeList) 116 { 117 if (nodeList == null || nodeList.getLength() == 0) 118 return null; 119 120 Node node = nodeList.item(0); 121 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 122 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 123 .getSourceLocatorFor(nodeHandler); 124 125 if (locator != null) 126 return locator.getPublicId(); 127 else 128 return null; 129 } 130 131 145 public static int lineNumber(ExpressionContext context) 146 { 147 Node contextNode = context.getContextNode(); 148 int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); 149 SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() 150 .getSourceLocatorFor(nodeHandler); 151 152 if (locator != null) 153 return locator.getLineNumber(); 154 else 155 return -1; 156 } 157 158 173 public static int lineNumber(NodeList nodeList) 174 { 175 if (nodeList == null || nodeList.getLength() == 0) 176 return -1; 177 178 Node node = nodeList.item(0); 179 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 180 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 181 .getSourceLocatorFor(nodeHandler); 182 183 if (locator != null) 184 return locator.getLineNumber(); 185 else 186 return -1; 187 } 188 189 203 public static int columnNumber(ExpressionContext context) 204 { 205 Node contextNode = context.getContextNode(); 206 int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); 207 SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() 208 .getSourceLocatorFor(nodeHandler); 209 210 if (locator != null) 211 return locator.getColumnNumber(); 212 else 213 return -1; 214 } 215 216 231 public static int columnNumber(NodeList nodeList) 232 { 233 if (nodeList == null || nodeList.getLength() == 0) 234 return -1; 235 236 Node node = nodeList.item(0); 237 int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); 238 SourceLocator locator = ((DTMNodeProxy)node).getDTM() 239 .getSourceLocatorFor(nodeHandler); 240 241 if (locator != null) 242 return locator.getColumnNumber(); 243 else 244 return -1; 245 } 246 } 247 | Popular Tags |