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.
Difference between revisions of "EclipseLink/Examples/SDO/MetadataXMLSchema"
< EclipseLink | Examples | SDO
(→Introspect Metadata - Types) |
|||
Line 17: | Line 17: | ||
<source lang="java"> | <source lang="java"> | ||
Type addressType = TypeHelper.INSTANCE.getType("http://www.example.org/customer-example", "address-type"); | Type addressType = TypeHelper.INSTANCE.getType("http://www.example.org/customer-example", "address-type"); | ||
+ | </source> | ||
+ | |||
+ | ==Introspect Metadata - Properties== | ||
+ | Once the XML schema has been processed the global attributes and elements are available as open content properties. | ||
+ | <source lang="java"> | ||
+ | Property phoneNumberProperty = | ||
+ | TypeHelper.INSTANCE.getOpenContentProperty("http://www.example.org/customer-example", "phone-number"); | ||
+ | </source> | ||
+ | You can also use XSDHelper to get the open content properties using XML information. This is useful when you have a global element and attribute in the same namspace with the same name. | ||
+ | <source lang="java"> | ||
+ | Property phoneNumberProperty = | ||
+ | XSDHelper.INSTANCE.getGlobalProperty("http://www.example.org/customer-example", "phone-number", true); | ||
</source> | </source> |
Revision as of 14:14, 24 February 2009
Contents
Overview
The following example will demonstrate how to use EclipseLink's SDO functionality to:
- Define a set of SDO Types from an XML Schema
Initializing the Types from XML Schema
The first thing that needs to be done in an SDO application is to set up the metadata for the Types and Properties. This is most commonly done by loading an XML schema, although it may also be done programmatically.
FileInputStream xsdInputStream = new FileInputStream("Customer.xsd"); XSDHelper.INSTANCE.define(xsdInputStream, null);
Introspect Metadata - Types
Once the XML schema has been processed the types are available from TypeHelper.
Type addressType = TypeHelper.INSTANCE.getType("http://www.example.org/customer-example", "address-type");
Introspect Metadata - Properties
Once the XML schema has been processed the global attributes and elements are available as open content properties.
Property phoneNumberProperty = TypeHelper.INSTANCE.getOpenContentProperty("http://www.example.org/customer-example", "phone-number");
You can also use XSDHelper to get the open content properties using XML information. This is useful when you have a global element and attribute in the same namspace with the same name.
Property phoneNumberProperty = XSDHelper.INSTANCE.getGlobalProperty("http://www.example.org/customer-example", "phone-number", true);