public void selected()

in java/src/org/apache/qetest/xalanj2/LoggingTraceListener.java [233:308]


    public void selected(SelectionEvent selectionEvent) 
            throws javax.xml.transform.TransformerException
    {
        counters[TYPE_SELECTED]++;

        Hashtable attrs = new Hashtable();
        attrs.put("event", "selected");
        attrs.put("location", "L" + selectionEvent.m_styleNode.getLineNumber()
                  + "C" + selectionEvent.m_styleNode.getColumnNumber());

        StringBuffer buf = new StringBuffer("  <styleNode>");
        ElemTemplateElement styleNodeElem = (ElemTemplateElement) selectionEvent.m_styleNode;
        ElemTemplateElement parent = (ElemTemplateElement) styleNodeElem.getParentNode();
        if (parent == styleNodeElem.getStylesheetRoot().getDefaultRootRule())
        {
            buf.append("[default-root-rule]");
        }
        else if (parent == styleNodeElem.getStylesheetRoot().getDefaultTextRule())
        {
            buf.append("[default-text-rule]");
        }
        else if (parent == styleNodeElem.getStylesheetRoot().getDefaultRule())
        {
            buf.append("[default-rule]");
        }
        else
            buf.append(XalanDumper.dump(styleNodeElem, XalanDumper.DUMP_DEFAULT));
        buf.append("  </styleNode>\n");

        buf.append("  <m_xpath>" + selectionEvent.m_attributeName + "="
                   + selectionEvent.m_xpath.getPatternString() + "</m_xpath>\n");

        buf.append("  <m_selection>");
        if (selectionEvent.m_selection.getType() == selectionEvent.m_selection.CLASS_NODESET)
        {
            NodeIterator nl = selectionEvent.m_selection.nodeset();

            if (nl instanceof ContextNodeList)
            {
                try
                {
                    nl = ((ContextNodeList)nl).cloneWithReset();
                }
                catch(CloneNotSupportedException cnse)
                {
                    buf.append("[Can't trace nodelist, threw: CloneNotSupportedException]");
                }
                Node pos = nl.nextNode();

                if (null == pos)
                {
                    buf.append("[empty node list]");
                }
                else // (null == pos)
                {
                    while (null != pos)
                    {
                        buf.append(" " + pos);
                        pos = nl.nextNode();
                    }
                }
            }
            else // (nl instanceof ContextNodeList)
            {
                buf.append("[Can't trace nodelist: it isn't a ContextNodeList]");
            }
        }
        else // (selectionEvent.m_selection.getType() == selectionEvent.m_selection.CLASS_NODESET)
        {
            buf.append("[" + selectionEvent.m_selection.str() +"]");
        }
        buf.append("</m_selection>\n");
        buf.append("  <m_sourceNode>" + XalanDumper.dump(selectionEvent.m_sourceNode, XalanDumper.DUMP_DEFAULT) + "</m_sourceNode>\n");
        setLastItem(buf.toString());
        logger.logElement(level, TRACE_LISTENER_DUMP, attrs, buf.toString());
    }