import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.OutputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import cda.ClinicalDocument; public class Transform2 { public static void main(String[] args) throws FileNotFoundException, JAXBException { ClinicalDocument xdww = load(new FileInputStream("/Users/aboufahj/Downloads/EHR_MedConnections_0_14101_pdf.xml")); //System.out.println("nom du chien :" + xdww.getTypeId().getRoot()); save(System.out, xdww); //String valid = XDWValidator.validateTXDWWorkflowDocument(xdww); //System.out.println(valid); } public static ClinicalDocument load(InputStream is) throws JAXBException{ JAXBContext jc = JAXBContext.newInstance("cda"); Unmarshaller u = jc.createUnmarshaller(); ClinicalDocument mimi = (ClinicalDocument)u.unmarshal(is); return mimi; } public static void save(OutputStream os, ClinicalDocument xdww) throws JAXBException{ JAXBContext jc = JAXBContext.newInstance( "cda" ); Marshaller m = jc.createMarshaller(); m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(xdww, os); } }