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"

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

Revision as of 13:40, 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