<!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. -->
<referenceid="ref.sdo-das-xml">
<title>SDO XML Data Access Service Functions</title>
<titleabbrev>XML DAS</titleabbrev>
<partintro>
<sectionid="sdo-das-xml.intro">
&reftitle.intro;
<para>
<!-- This warns that the extension is experimental -->
&warn.experimental;
</para>
<para>
In order to use the XML Data Access Service for Service Data Objects, you will need to understand some of the concepts behind SDO: the data graph, the data object, XPath and property expressions, and so on.
If you are not familiar with these ideas, you might want to look first at
<linklinkend='ref.sdo'>the section on SDO</link>
.
</para>
<para>
The job of the XML DAS is to move data between the application and an XML data source.
In order to do this it needs to be told the XML schema the XML should follow.
This model information is used to ensure conformance of XML being written out, and also to ensure that
modifications made to an SDO originating from XML follow the model described by the XML schema.
</para>
<para>
The XML DAS currently supports reading/writing XML to/from a file or an http URL (for example, to support RSS feeds).
</para>
</section>
<sectionid="sdo-das-xml.requirements">
&reftitle.required;
<para>
The SDO XML Data Access Service requires PHP 5.1 or higher. It is packaged with the SDO extension and requires SDO to have been installed.
The <ulinkurl='&url.ibm.sdo;'>SDO 2.0 specification</ulink> defines the mapping between XML types and SDO types. With Java SDO, this mapping is implemented by the XMLHelper. With SDO for PHP, this mapping is implemented by the XML Data Access Services. The XML DAS implements the mapping described in the SDO 2.0 specification with the following restrictions:
The examples assume the XML Schema for the letter is contained in a the file
<filename>letter.xsd</filename>
and the letter instance is in the file
<filename>letter.xml</filename>
. </para>
<example>
<title>Working with the SDO_DAS_XML Class</title>
<para>
The following example shows how to create a SDO_DAS_XML Object and use it to load an instance document.
The SDO_XML_DAS object can be created by passing the xsd file to the SDO_DAS_XML::create method, which is a static method of SDO_DAS_XML Class. This schema file(XSD Document) can be either file available on the local file system or it can be an URL.
Once we have created the SDO_XML_DAS Object, we can use the same to load the instance document using loadFromFile method. loadFromString method can be used if want load xml instance document which is available as string.
On successful loading of the instance document, you will be returned with an object of type SDO_DAS_XML_Document. Use the getRootDataObject method of SDO_DAS_XML_Document class to get the root DataObject.
This example also tries to modify the properties of the root DataObject and then write the changed contents back to file system.
The above example shown, how to use the SDO_XML_DAS object to load an existing instance document and change the DataObject(property values) and write the changes back to file system.
This example shows, how to create the DataObjects dynamically and save them as a xml string. Please note that this example uses a company schema((<linklinkend="sdo.examples">company.xsd</link>)) as defined in SDO samples section.
This example shows you how to create the DataObject and use the Sequence API (<linklinkend="sdo.sample.sequence">For more information on Sequence API</link>) to construct a letter containing unstructured text.
<title>Working with the SDO_DAS_XML_Document Class</title>
<para>
This example shows you how to use the SDO_DAS_XML_Document class. SDO_DAS_XML_Document class is provided to get/set XML declarations such as version, schema location, encoding etc.
print("Encoding is set to : " . $xdoc->getEncoding());
print("XML Version : " . $xdoc->getXMLVersion();
$xdoc->setXMLVersion("1.1");
print($xmldas->saveDocumentToString($xdoc));
} catch (SDO_TypeNotFoundException $e) {
print("Type is not defined in the xsd file");
} catch (SDO_DAS_XML_ParserException $e) {
print("Problem while parsing");
}
?>
]]>
</programlisting>
</example>
</section>
<!-- class definition section -->
<sectionid='sdo-das-xml.classes'>
&reftitle.classes;
<para>
The XML DAS provides three classes. The SDO_DAS_XML which is the main class used to fetch the data from the XML source and also can used to write the data back.
The next one is SDO_DAS_XML_Document class, which is basically useful to get/set the XML declarations such as encoding, version etc. And the last class is SDO_DAS_XML_ParserException which will be thrown for any parser exceptions while loading xsd/xml file.
</para>
<sectionid='sdo-das-xml.class.sdo_das_xml'>
<title>
<classname>SDO_DAS_XML</classname>
</title>
<para>
This is the main class of XML DAS, which is used fetch the data from the xml source and also used to write the data back. Other than the methods to load and save xml files, it also has a method called createDataObject which can be used to create an empty DataObject of a given type.