org.apache.tuscany.samples.sdo.specExampleSection
Class AccessDataObjectsUsingXPath
java.lang.Object
org.apache.tuscany.samples.sdo.specExampleSection.AccessDataObjectsUsingXPath
public class AccessDataObjectsUsingXPath
- extends java.lang.Object
Demonstrates accessing the properties of a DataObject using XPath queries.
The following sample is from the Apache Tuscany project. It was written to help users
understand and experiement with SDO. It is based upon example code contained
within, and is meant for use with, and reference to the SDO Specification. In general this sample attempts to use the
code and comments contained within the specification, exceptions to this are noted
in comments.
This specific sample is based upon the AccessDataObjectsUsingXPath example from
the Examples section of the SDO specification. It shows the use of DataObjects and
the XMLHelper and demonstrates accessing the properties of a DataObject using
XPath queries.
This sample reads an xml file representing a DataObject of a company. A
DataAccessService (DAS) is simply a component which creates a DataGraph or
DataObject, it can also be responcible for creating SDO Types for created
DataObjects. In order to create a DataObject or DataGraph this sample relies upon
XMLHelper class which is essentially an example of a XML DAS. The code shown here
would work just as well against an equivalent DataGraph or DataObject that was
provided by any DAS that creates an identical DataObject/DataGraph of the same
Type used here.
To define the correct Types for each DataObject ( CompanyType, DepartmentType etc )
this sample relies upon
SdoSampleConstants.COMPANY_XSD
which is
provided in the resources directory of these samples. The xml file
SdoSampleConstants.COMPANY_DATAOBJECT_XML
used to load the DataObject is also located in this resources directory. The xsd
the xml was generated by
CreateCompany
which is a good
resource for how to populate or create DataObjects or DataGraphs dynamically.
The following example has the same effect as
org.apache.tuscany.samples.sdo.specExampleSection.AccessDataObjectsViaPropertyIndex
.
Usage:
This sample can easily be run from within Eclipse as a Java Application if tuscany or
the sample-sdo project is imported into Eclipse as an existing project.
If executing as a standalone application please do the following:
- Include the following jar files on your classpath :
- SDO API and Tuscany Implementation
- sdo-api-{version}.jar - SDO API
- tuscany-sdo-impl-{version}.jar - Tuscany SDO implementation
- EMF dependencies.
- emf-common-{version}.jar - some common framework utility and base classes
- emf-ecore-{version}.jar - the EMF core runtime implementation classes (the Ecore metamodel)
- emf-ecore-change-{version}.jar - the EMF change recorder and framework
- emf-ecore-xmi-{version}.jar - EMF's default XML (and XMI) serializer and loader
- xsd-{version}.jar - the XML Schema model
These jar files can be obtained by downloading and unpacking a Tuscany binary distribution
- Execute:
java org.apache.tuscany.samples.sdo.specExampleSection.AccessDataObjectsUsingXPath
- Author:
- Robbie Minshall
- See Also:
ObtainingDataGraphFromXml
Method Summary |
static void |
main(java.lang.String[] args)
Execute this method in order to run the sample. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AccessDataObjectsUsingXPath
public AccessDataObjectsUsingXPath()
main
public static void main(java.lang.String[] args)
- Execute this method in order to run the sample.
- Parameters:
args
-
Copyright © 2007 Apache Software Foundation. All Rights Reserved.