Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/SDO/SdoStatic"

m
Line 3: Line 3:
 
<br>XSDHelper.INSTANCE.define(xsdInputStream, null);
 
<br>XSDHelper.INSTANCE.define(xsdInputStream, null);
 
 
<br>// Unmarshal the XML document
+
// Unmarshal the XML document
 
<br>FileInputStream xmlInputStream = new FileInputStream("../Resource/bin/Customer-data.xml");
 
<br>FileInputStream xmlInputStream = new FileInputStream("../Resource/bin/Customer-data.xml");
 
<br>XMLDocument xmlDocument = XMLHelper.INSTANCE.load(xmlInputStream);
 
<br>XMLDocument xmlDocument = XMLHelper.INSTANCE.load(xmlInputStream);
 
<br>CustomerType customer = (CustomerType) xmlDocument.getRootObject();
 
<br>CustomerType customer = (CustomerType) xmlDocument.getRootObject();
  
<br>// Modify the Java object
+
// Modify the Java object
 
<br>PhoneNumber phoneNumber = (PhoneNumber) DataFactory.INSTANCE.create("urn:customer-<br>example", "phone-number");
 
<br>PhoneNumber phoneNumber = (PhoneNumber) DataFactory.INSTANCE.create("urn:customer-<br>example", "phone-number");
 
<br>phoneNumber.setNumberType("home");
 
<br>phoneNumber.setNumberType("home");
Line 14: Line 14:
 
<br>customer.getContactInfo().getPhoneNumber().add(phoneNumber);
 
<br>customer.getContactInfo().getPhoneNumber().add(phoneNumber);
 
 
<br>// Marshal the Java object
+
// Marshal the Java object
 
<br>XMLHelper.INSTANCE.save(xmlDocument, System.out, null);
 
<br>XMLHelper.INSTANCE.save(xmlDocument, System.out, null);

Revision as of 13:41, 22 October 2007

// Initialize the the metadata
FileInputStream xsdInputStream = new FileInputStream("../Resource/bin/Customer.xsd");
XSDHelper.INSTANCE.define(xsdInputStream, null);

// Unmarshal the XML document
FileInputStream xmlInputStream = new FileInputStream("../Resource/bin/Customer-data.xml");
XMLDocument xmlDocument = XMLHelper.INSTANCE.load(xmlInputStream);
CustomerType customer = (CustomerType) xmlDocument.getRootObject();

// Modify the Java object
PhoneNumber phoneNumber = (PhoneNumber) DataFactory.INSTANCE.create("urn:customer-
example", "phone-number");
phoneNumber.setNumberType("home");
phoneNumber.setValue("(613) 555-3333");
customer.getContactInfo().getPhoneNumber().add(phoneNumber);

// Marshal the Java object
XMLHelper.INSTANCE.save(xmlDocument, System.out, null);

Back to the top