xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pauld...@apache.org
Subject cvs commit: xml-xalan/test/java/src/org/apache/qetest/dtm TestDTMTraverser.java
Date Tue, 09 Apr 2002 21:05:30 GMT
pauldick    02/04/09 14:05:30

  Modified:    test/java/src/org/apache/qetest/dtm TestDTMTraverser.java
  Log:
  Added traverser for Ancestor and Descendant,  and changed
  to simplified source document.
  
  Revision  Changes    Path
  1.2       +31 -8     xml-xalan/test/java/src/org/apache/qetest/dtm/TestDTMTraverser.java
  
  Index: TestDTMTraverser.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/dtm/TestDTMTraverser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestDTMTraverser.java	9 Apr 2002 14:20:23 -0000	1.1
  +++ TestDTMTraverser.java	9 Apr 2002 21:05:30 -0000	1.2
  @@ -111,8 +111,7 @@
   			String defaultSource=
   				"<?xml version=\"1.0\"?>\n"+
   				"<Document>"+
  -				"<A><B hat=\"new\" car=\"Honda\" dog=\"Boxer\">NodeB</B></A>"+
  -				"<C>NodeC<D/>Words</C>"+
  +				"<A><B><C><D><E><F/></E></D></C></B></A><Aa/>"+
   				"</Document>";
   
   			source=new StreamSource(new StringReader(defaultSource));
  @@ -135,17 +134,41 @@
         DTMManager manager= new DTMManagerDefault().newInstance(new XMLStringFactoryImpl());
         DTM dtm=manager.getDTM(source, true, null, false, true);
   
  -	  // Get the root node and then the first child.
  -	  int parent = dtm.getDocument();
  -	  parent = dtm.getFirstChild(parent);
  +	  // Get the Document node and then the first child.
  +	  int dtmRoot = dtm.getDocument();			// #document
  +	  int child = dtm.getFirstChild(dtmRoot);	// <Document>
  +	  int sndChild = dtm.getFirstChild(child);	// <A>
         
   	  // Get a traverser for CHILD:: axis.
  +	  System.out.println("#### First Traverser for <Document>\n");			   
         DTMAxisTraverser at = dtm.getAxisTraverser(Axis.CHILD);
   
   	  // Traverse the axis and print out node info.
  -      for (int child = at.first(parent); DTM.NULL != child;
  -              child = at.next(parent, child))
  -		printNode(dtm, child, " ");
  +      for (int atNode = at.first(child); DTM.NULL != atNode;
  +              atNode = at.next(child, atNode))
  +		printNode(dtm, atNode, " ");
  +
  +	  // Get a traverser for DESCENDANT:: axis.
  +	  System.out.println("#### Second Traverser for <A>\n");
  +      DTMAxisTraverser at2 = dtm.getAxisTraverser(Axis.DESCENDANT);
  +
  +	  // Traverse the axis and print out node info.
  +	  int lastNode = 0;
  +      for (int atNode = at2.first(sndChild); DTM.NULL != atNode;
  +              atNode = at2.next(sndChild, atNode))
  +		{
  +			printNode(dtm, atNode, " ");
  +			lastNode = atNode;
  +		}
  +
  +	  // Get a traverser for ANCESTOR:: axis.
  +	  System.out.println("#### Third Traverser for <F>\n");
  +      DTMAxisTraverser at3 = dtm.getAxisTraverser(Axis.ANCESTOR);
  +
  +	  // Traverse the axis and print out node info.
  +      for (int atNode = at3.first(lastNode); DTM.NULL != atNode;
  +              atNode = at3.next(lastNode, atNode))
  +		printNode(dtm, atNode, " ");
   
       }
       catch(Exception e)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message