Search in sources :

Example 1 with DTMNodeProxy

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;
}
Also used : SourceLocator(javax.xml.transform.SourceLocator) Node(org.w3c.dom.Node) DTMNodeProxy(org.apache.xml.dtm.ref.DTMNodeProxy)

Example 2 with DTMNodeProxy

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());
    }
}
Also used : XPath(org.apache.xpath.XPath) Debugger(org.intellij.plugins.xsltDebugger.rt.engine.Debugger) Node(org.w3c.dom.Node) PrefixResolver(org.apache.xml.utils.PrefixResolver) TransformerException(javax.xml.transform.TransformerException) DTMIterator(org.apache.xml.dtm.DTMIterator) DTM(org.apache.xml.dtm.DTM) DTMNodeProxy(org.apache.xml.dtm.ref.DTMNodeProxy) PrefixResolverDefault(org.apache.xml.utils.PrefixResolverDefault)

Aggregations

DTMNodeProxy (org.apache.xml.dtm.ref.DTMNodeProxy)2 Node (org.w3c.dom.Node)2 SourceLocator (javax.xml.transform.SourceLocator)1 TransformerException (javax.xml.transform.TransformerException)1 DTM (org.apache.xml.dtm.DTM)1 DTMIterator (org.apache.xml.dtm.DTMIterator)1 PrefixResolver (org.apache.xml.utils.PrefixResolver)1 PrefixResolverDefault (org.apache.xml.utils.PrefixResolverDefault)1 XPath (org.apache.xpath.XPath)1 Debugger (org.intellij.plugins.xsltDebugger.rt.engine.Debugger)1