1 9 10 package test.dom4j.rule; 11 12 import junit.framework.Test; 13 import junit.framework.TestSuite; 14 import junit.textui.TestRunner; 15 import org.dom4j.Node; 16 import org.dom4j.io.SAXReader; 17 import org.dom4j.rule.Action; 18 import org.dom4j.rule.Stylesheet; 19 20 26 public class TestStylesheet2 extends TestStylesheet { 27 28 protected String [] templates = { 29 "/", 30 "title", 31 "para", 32 "*", 33 }; 34 35 public static void main( String [] args ) { 38 TestRunner.run( suite() ); 39 } 40 41 public static Test suite() { 42 return new TestSuite( TestStylesheet2.class ); 43 } 44 45 public TestStylesheet2(String name) { 46 super(name); 47 } 48 49 public void testRules() throws Exception { 52 for ( int i = 0, size = templates.length; i < size; i++ ) { 53 addTemplate( templates[i] ); 54 } 55 56 log( "" ); 57 log( "........................................" ); 58 log( "" ); 59 log( "Running stylesheet" ); 60 61 stylesheet.run( document ); 62 63 log( "Finished" ); 64 } 65 66 67 public void setUp() throws Exception { 70 SAXReader reader = new SAXReader(); 71 document = reader.read( "xml/test/littledoc.xml" ); 72 73 stylesheet = new Stylesheet(); 74 stylesheet.setValueOfAction( 75 new Action() { 76 public void run(Node node) { 77 log( "Default ValueOf action on node: " + node ); 78 log( "........................................" ); 79 } 80 } 81 ); 82 } 83 } 84 85 86 87 88 132 | Popular Tags |