use of org.apache.xml.dtm.ref.DTMNodeProxy in project webtools.sourceediting by eclipse.
the class XalanStyleFrame method getSourceLocator.
private SourceLocator getSourceLocator() {
Node sourceNode = event.m_sourceNode;
SourceLocator locator = null;
if (sourceNode instanceof DTMNodeProxy) {
int nodeHandler = ((DTMNodeProxy) sourceNode).getDTMNodeNumber();
return ((DTMNodeProxy) sourceNode).getDTM().getSourceLocatorFor(nodeHandler);
}
return null;
}
use of org.apache.xml.dtm.ref.DTMNodeProxy in project intellij-community by JetBrains.
the class XalanStyleFrame method eval.
public Value eval(String expr) throws Debugger.EvaluationException {
assert isValid();
try {
final DTMIterator context = myTransformer.getContextNodeList();
final int ctx;
final DTM dtm = context.getDTM(myCurrentNode);
if (dtm.getDocumentRoot(myCurrentNode) == myCurrentNode) {
ctx = dtm.getFirstChild(myCurrentNode);
} else {
ctx = myCurrentNode;
}
final DTMNodeProxy c = new DTMNodeProxy(dtm, ctx);
final PrefixResolver prefixResolver = new PrefixResolverDefault(c) {
public String getNamespaceForPrefix(String prefix, Node context) {
if (context instanceof DTMNodeProxy) {
final DTMNodeProxy proxy = (DTMNodeProxy) context;
final DTM dtm = proxy.getDTM();
int p = proxy.getDTMNodeNumber();
while (p != DTM.NULL) {
int nsNode = dtm.getFirstNamespaceNode(p, true);
while (nsNode != DTM.NULL) {
final String s = dtm.getLocalName(nsNode);
if (s.equals(prefix)) {
return dtm.getNodeValue(nsNode);
}
nsNode = dtm.getNextNamespaceNode(p, nsNode, true);
}
p = dtm.getParent(p);
}
}
return super.getNamespaceForPrefix(prefix, context);
}
};
final XPath xPath = new XPath(expr, myCurrentElement, prefixResolver, XPath.SELECT, myTransformer.getErrorListener());
return new XObjectValue(xPath.execute(myContext, myCurrentNode, myCurrentElement));
} catch (Exception e) {
debug(e);
final String message = e.getMessage();
throw new Debugger.EvaluationException(message != null ? message : e.getClass().getSimpleName());
}
}
Aggregations