1 19 20 import java.io.File ; 21 import java.io.FileInputStream ; 22 import java.io.FileOutputStream ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 26 import org.enhydra.zeus.Source; 28 import org.enhydra.zeus.Marshaller; 29 import org.enhydra.zeus.Unmarshaller; 30 import org.enhydra.zeus.result.StreamResult; 31 import org.enhydra.zeus.source.StreamSource; 32 33 import samples.xsd.ARTIST; 35 import samples.xsd.SONGS; 36 import samples.xsd.SONG; 37 import samples.xsd.TITLE; 38 39 public class TestSongsXSD { 40 41 public static void main(String [] args) { 42 if (args.length != 1) { 43 System.out.println("Usage: java TestSongsXSD " + 44 "[songs.xml location]"); 45 return; 46 } 47 48 try { 49 Source source = new StreamSource( 50 new FileInputStream (new File (args[0]))); 51 Unmarshaller unmarshaller = new Unmarshaller(); 52 Object o = unmarshaller.unmarshal(source).getObject(); 53 54 70 Marshaller marshaller = new Marshaller(); 71 marshaller.marshal(o, new StreamResult( 72 new FileOutputStream (new File ("output.xml")))); 73 } catch (Exception e) { 74 e.printStackTrace(); 75 } 76 } 77 } 78 | Popular Tags |