WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform
Examples

Examples

Table of Contents

Basic Usage

The examples below assume an SDO created with the schema and instance information shown below, using the XML Data Access Service.

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'.

 <?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> 

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'.

 <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> 

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 sdoxml:propertyType attribute specifying the type of the non-containment reference.