SDO XML Data Access Service Functions
Внимание. Это расширение является ЭКСПЕРИМЕНТАЛЬНЫМ. Поведение этого расширения, включая имена его функций и относящуюся к нему документацию, может измениться в последующих версиях PHP без уведомления. Используйте это расширение на свой страх и риск.
- 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 the section on SDO .
- The job of the XML DAS is to move data between the application and an XML data source, which can be either a file or a URL. In order to do this it needs to be told the location of the XML schema, which is passed as a parameter to the create method of the XML DAS. The schema 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.
- The SDO XML Data Access Service requires PHP5.1 or higher. It is packaged with the SDO extension and requires SDO to have been installed. See the SDO installation instructions for the details of how to do this.
- The XML Data Access Service is packaged and installed as part of the SDO extension. Please Refer SDO installation instructions.
- The SDO 2.0 specification 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 following examples are based on the letter example described in the SDO documentation. The examples assume the XML Schema for the letter is contained in a file letter.xsd and the letter instance is in the file letter.xml. These two files are reproduced here:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:letter="http://letterSchema" targetNamespace="http://letterSchema"> <xsd:element name="letters" type="letter:FormLetter"/> <xsd:complexType name="FormLetter" mixed="true"> <xsd:sequence> <xsd:element name="date" minOccurs="0" type="xsd:string"/> <xsd:element name="firstName" minOccurs="0" type="xsd:string"/> <xsd:element name="lastName" minOccurs="0" type="xsd:string"/> </xsd:sequence> </xsd:complexType> |
<letter:letters xmlns:letter="http://letterSchema"> <date>March 1, 2005</date> Mutual of Omaha Wild Kingdom, USA Dear <firstName>Casy</firstName> <lastName>Crocodile</lastName> Please buy more shark repellent. Your premium is past due. |
Пример 2. Creating a new XML document - The previous example loaded the document from a file. This example shows how to create an SDO data graph in memory. In this example it is then saved to an XML string. Furthermore, because the letter contains both structured and unstructured content, it uses - the Sequence API as well assignments to properties to construct the data graph.
|
- This will emit the following output (line breaks have been inserted for readability):
<?xml version="1.0" encoding="UTF-8"?> |
Пример 3. Setting XML document properties - This third example shows you how to use the SDO_DAS_XML_Document class. SDO_DAS_XML_Document class is provided to get and set properties of the XML declaration such as version, schema location, encoding and so on.
- The first three lines of output show how the encoding and XML version has been obtained from the document, and how the XML version has been set in the XML header.
|
- 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.
- 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.
- This class can be used to get/set XML Declarations such as encoding, schema location etc.
- Is a subclass of SDO_Exception . Thrown for any parser errors while loading the xsd/xml file.
Содержание
SDO_DAS_XML_Document::getEncoding -- Returns encoding string.
SDO_DAS_XML_Document::getNoNamespaceSchemaLocation -- Returns no namespace schema location.
SDO_DAS_XML_Document::getRoorDataObject -- Returns the root SDO_DataObject.
SDO_DAS_XML_Document::getRootElementName -- Returns root element's name.
SDO_DAS_XML_Document::getRootElementURI -- Returns root element's URI string.
SDO_DAS_XML_Document::getSchemaLocation -- Returns schema location.
SDO_DAS_XML_Document::getXMLDeclaration -- Returns whether the xml declaration is set or not.
SDO_DAS_XML_Document::getXMLVersion -- Returns xml declaration string.
SDO_DAS_XML_Document::setEncoding -- Sets the given string as encoding.
SDO_DAS_XML_Document::setNoNamespaceSchemaLocation -- Sets the given string as no namespace schema location.
SDO_DAS_XML_Document::setSchemaLocation -- Sets the given string as schema location.
SDO_DAS_XML_Document::setXMLDeclaration -- Sets the xml declaration.
SDO_DAS_XML_Document::setXMLVersion -- Sets the given string as xml version.
SDO_DAS_XML::create -- To create SDO_DAS_XML object for a given schema file.
SDO_DAS_XML::createDataObject -- Creates SDO_DataObject for a given namespace URI and type name.
SDO_DAS_XML::loadFromFile -- Returns SDO_DAS_XML_Document object for a given path to xml instance document.
SDO_DAS_XML::loadFromString -- Returns SDO_DAS_XML_Document for a given xml instance string.
SDO_DAS_XML::saveDataObjectToFile -- Saves the SDO_DataObject object to File.
SDO_DAS_XML::saveDataObjectToString -- Saves the SDO_DataObject object to string.
SDO_DAS_XML::saveDocumentToFile -- Saves the SDO_DAS_XML_Document object to a file.
SDO_DAS_XML::saveDocumentToString -- Saves the SDO_DAS_XML_Document object to a string.
runkit_superglobals
SDO_DAS_XML_Document::getEncoding 22222