Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Examples/MOXy/Dynamic/DynamicEntityToXml

< EclipseLink‎ | Examples‎ | MOXy‎ | Dynamic
Revision as of 17:01, 17 June 2010 by Blaise.doughan.oracle.com (Talk | contribs) (New page: ==Overview== In this example we will show how to create dynamic entities and marshal then to XML. ==Create Dynamic Entities== <source lang="java"> DynamicEntity customer = jaxbContext.new...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

In this example we will show how to create dynamic entities and marshal then to XML.

Create Dynamic Entities

DynamicEntity customer = jaxbContext.newDynamicEntity("org.example.customer.Customer");
customer.set("name", "Jane Doe");
 
DynamicEntity address = jaxbContext.newDynamicEntity("org.example.customer.Address");
address.set("street", "1 Any Street");
address.set("city", "Any Town");
customer.set("address", address);

Marshal Dynamic Entities to XML

Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(customer, System.out);

Copyright © Eclipse Foundation, Inc. All Rights Reserved.