1 7 8 package org.dom4j.xpath; 9 10 import junit.textui.TestRunner; 11 12 import java.io.File ; 13 import java.util.List ; 14 15 import org.dom4j.AbstractTestCase; 16 import org.dom4j.io.SAXReader; 17 18 24 public class SortByTest extends AbstractTestCase { 25 public static void main(String [] args) { 26 TestRunner.run(SortByTest.class); 27 } 28 29 public void testXPaths() throws Exception { 32 List list = document.selectNodes("//SPEAKER", "NAME"); 33 34 log("Number of SPEAKER instances: " + list.size()); 35 36 List noDuplicates = document.selectNodes("//SPEAKER", ".", true); 37 38 log("Number of distinct SPEAKER instances: " + noDuplicates.size()); 39 40 log("Number of distinct SPEAKER instances: " + noDuplicates.size()); 41 } 42 43 protected void setUp() throws Exception { 44 super.setUp(); 45 document = new SAXReader().read(new File ("xml/much_ado.xml")); 46 } 47 } 48 49 85 | Popular Tags |