sboag       00/10/31 09:31:28

  Modified:    java/src/org/apache/xalan/trace PrintTraceListener.java
  Log:
  For the selected method, if the type is an itterator, test for 
ContextNodeList.
  If it is a ContextNodeList, do cloneWithReset.  Otherwise
  simply spit out a message that says, can't do it.
  
  Revision  Changes    Path
  1.3       +28 -11    
xml-xalan/java/src/org/apache/xalan/trace/PrintTraceListener.java
  
  Index: PrintTraceListener.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/trace/PrintTraceListener.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PrintTraceListener.java   2000/10/30 18:56:52     1.2
  +++ PrintTraceListener.java   2000/10/31 17:31:26     1.3
  @@ -65,6 +65,7 @@
   import org.apache.xalan.templates.ElemTemplateElement;
   import org.apache.xalan.templates.ElemTextLiteral;
   import org.apache.xalan.templates.Constants;
  +import org.apache.xpath.axes.ContextNodeList;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -166,7 +167,7 @@
     }
   
     /**
  -   * Method that is called just after the formatter listener is called.
  +   * Method that is called just after a select attribute has been evaluated.
      *
      * @param ev the generate event.
      *
  @@ -216,20 +217,36 @@
           m_pw.println();
   
           NodeIterator nl = ev.m_selection.nodeset();
  -        Node pos = nl.nextNode();
  -
  -        if (null == pos)
  -        {
  -          m_pw.println("     [empty node list]");
  -        }
  -        else
  +        if(nl instanceof ContextNodeList)
           {
  -          while (null != pos)
  +          try
  +          {
  +            nl = ((ContextNodeList)nl).cloneWithReset();
  +          }
  +          catch(CloneNotSupportedException cnse)
  +          {
  +            m_pw.println("     [Can't trace nodelist because it it threw a 
CloneNotSupportedException]");
  +            return;
  +          }
  +          Node pos = nl.nextNode();
  +
  +          if (null == pos)
  +          {
  +            m_pw.println("     [empty node list]");
  +          }
  +          else
             {
  -            m_pw.println("     " + pos);
  +            while (null != pos)
  +            {
  +              m_pw.println("     " + pos);
   
  -            pos = nl.nextNode();
  +              pos = nl.nextNode();
  +            }
             }
  +        }
  +        else
  +        {
  +            m_pw.println("     [Can't trace nodelist because it isn't a 
ContextNodeList]");
           }
         }
         else
  
  
  

Reply via email to