Search in sources :

Example 11 with IMarshallingContext

use of org.jibx.runtime.IMarshallingContext in project kernel by exoplatform.

the class TestConfigurationService method testMarshallAndUnmarshall.

public void testMarshallAndUnmarshall() throws Exception {
    String basedir = System.getProperty("basedir");
    ConfigurationUnmarshaller unmarshaller = new ConfigurationUnmarshaller();
    URL url = TestConfigurationService.class.getResource("../../../../configuration.xml");
    Object obj = unmarshaller.unmarshall(url);
    IBindingFactory bfact = BindingDirectory.getFactory(Configuration.class);
    IMarshallingContext mctx = bfact.createMarshallingContext();
    mctx.setIndent(2);
    mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream(basedir + "/target/configuration.xml"));
}
Also used : IMarshallingContext(org.jibx.runtime.IMarshallingContext) IBindingFactory(org.jibx.runtime.IBindingFactory) FileOutputStream(java.io.FileOutputStream) URL(java.net.URL)

Example 12 with IMarshallingContext

use of org.jibx.runtime.IMarshallingContext in project kernel by exoplatform.

the class TestDataXML method testMarshallAndUnmarshall.

public void testMarshallAndUnmarshall() throws Exception {
    String projectdir = System.getProperty("basedir");
    IBindingFactory bfact = BindingDirectory.getFactory(XMLObject.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    URL url = TestDataXML.class.getResource("../../../../object.xml");
    Object obj = uctx.unmarshalDocument(url.openStream(), null);
    IMarshallingContext mctx = bfact.createMarshallingContext();
    mctx.setIndent(2);
    mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream(projectdir + "/target/object.xml"));
}
Also used : IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) IMarshallingContext(org.jibx.runtime.IMarshallingContext) IBindingFactory(org.jibx.runtime.IBindingFactory) FileOutputStream(java.io.FileOutputStream) XMLObject(org.exoplatform.xml.object.XMLObject) URL(java.net.URL)

Aggregations

IMarshallingContext (org.jibx.runtime.IMarshallingContext)12 IBindingFactory (org.jibx.runtime.IBindingFactory)9 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 URL (java.net.URL)2 JiBXException (org.jibx.runtime.JiBXException)2 IOException (java.io.IOException)1 XMLObject (org.exoplatform.xml.object.XMLObject)1 IUnmarshallingContext (org.jibx.runtime.IUnmarshallingContext)1