1 17 package org.apache.commons.digester.plugins; 18 19 import org.xml.sax.Attributes ; 20 import org.apache.commons.digester.Rule; 21 22 25 public class DumperRule extends Rule { 26 public void begin(String namespace, String name, Attributes attributes) 27 throws Exception { 28 System.out.print("<"); 29 System.out.print(name); 30 31 int nAttributes = attributes.getLength(); 32 for(int i=0; i<nAttributes; ++i) { 33 String key = attributes.getQName(i); 34 String value = attributes.getValue(i); 35 System.out.print(" "); 36 System.out.print(key); 37 System.out.print("="); 38 System.out.print("'"); 39 System.out.print(value); 40 System.out.print("'"); 41 } 42 System.out.println(">"); 43 } 44 45 public void body(String namespace, String name, String text) 46 throws Exception { 47 System.out.print(text); 48 } 49 50 public void end(String namespace, String name) 51 throws Exception { 52 System.out.print("</"); 53 System.out.print(name); 54 System.out.println(">"); 55 } 56 } 57 | Popular Tags |