<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Basic usage</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sdo.examples.html">Examples</a></div> <div class="next" style="text-align: right; float: right;"><a href="sdo.sample.getset.html">Setting and Getting Property Values</a></div> <div class="up"><a href="sdo.examples.html">Examples</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="sdo.examples-basic" class="section"> <h2 class="title">Basic usage</h2> <p class="para"> The examples below assume an SDO created with the schema and instance information shown below, using the XML Data Access Service. </p> <p class="para"> The instance document below describes a single company, called 'MegaCorp', which contains a single department, called 'Advanced Technologies'. The Advanced Technologies department contains three employees. The company employeeOfTheMonth is referencing the second employee, 'Jane Doe'. </p> <p class="para"> <div class="example-contents"> <div class="xmlcode"><pre class="xmlcode"><?xml version="1.0" encoding="UTF-8" ?> <company xmlns="companyNS" name="MegaCorp" employeeOfTheMonth="E0003"> <departments name="Advanced Technologies" location="NY" number="123"> <employees name="John Jones" SN="E0001"/> <employees name="Jane Doe" SN="E0003"/> <employees name="Al Smith" SN="E0004" manager="true"/> </departments> </company></pre> </div> </div> </p> <p class="para"> The root element of the schema is a company. The company contains departments, and each department contains employees. Each element has a number of attributes to store things like name, serial number, and so on. Finally, the company also has an IDREF attribute which identifies one of the employees as the 'employeeOfTheMonth'. </p> <p class="para"> <div class="example-contents"> <div class="xmlcode"><pre class="xmlcode"><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoxml="commonj.sdo/xml" xmlns:company="companyNS" targetNamespace="companyNS"> <xsd:element name="company" type="company:CompanyType"/> <xsd:complexType name="CompanyType"> <xsd:sequence> <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="name" type="xsd:string"/> <xsd:attribute name="employeeOfTheMonth" type="xsd:IDREF" sdoxml:propertyType="company:EmployeeType"/> </xsd:complexType> <xsd:complexType name="DepartmentType"> <xsd:sequence> <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="name" type="xsd:string"/> <xsd:attribute name="location" type="xsd:string"/> <xsd:attribute name="number" type="xsd:int"/> </xsd:complexType> <xsd:complexType name="EmployeeType"> <xsd:attribute name="name" type="xsd:string"/> <xsd:attribute name="SN" type="xsd:ID"/> <xsd:attribute name="manager" type="xsd:boolean"/> </xsd:complexType> </xsd:schema></pre> </div> </div> </p> <p class="para">The XML Data Access Service maps the schema to an SDO. Attributes such as "name" become primitive properties, the sequence of employees becomes a many-valued containment relationship, and so on. Note that the containment relationships are expressed as one complex type within another, whereas non-containment references are expressed in terms of ID and IDREF, with a special <strong class="command">sdoxml:propertyType</strong> attribute specifying the type of the non-containment reference. </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sdo.examples.html">Examples</a></div> <div class="next" style="text-align: right; float: right;"><a href="sdo.sample.getset.html">Setting and Getting Property Values</a></div> <div class="up"><a href="sdo.examples.html">Examples</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>