1 19 20 import java.io.FileInputStream ; 21 22 import org.enhydra.zeus.Marshaller; 24 import org.enhydra.zeus.Result; 25 import org.enhydra.zeus.Source; 26 import org.enhydra.zeus.Unmarshaller; 27 import org.enhydra.zeus.source.StreamSource; 28 import org.enhydra.zeus.result.StreamResult; 29 30 37 public class TestZeusRoundTrip { 38 39 42 public static void main (String args[]) { 43 String javaPackage = ""; 44 if (args.length < 1) { 45 System.out.println("Please specify an XML file."); 46 System.exit(1); 47 } else if (args.length >= 2) { 48 javaPackage = args[1]; 49 } 50 51 try { 52 Source source = new StreamSource(new FileInputStream (args[0])); 53 Unmarshaller unmarshaller = new Unmarshaller(); 54 unmarshaller.setJavaPackage(javaPackage); 55 Object obj = unmarshaller.unmarshal(source); 56 System.out.println("Unmarshalled object = " + obj); 57 58 Marshaller marshaller = new Marshaller(); 59 Result result = new StreamResult(System.out); 60 marshaller.marshal(obj, result); 61 62 } catch (Exception e) { 63 e.printStackTrace(); 64 } 65 } 66 67 } 68 | Popular Tags |