diff --git a/reference/sdo_das_xml/reference.xml b/reference/sdo_das_xml/reference.xml index 681e192eb0..daa1cfb333 100644 --- a/reference/sdo_das_xml/reference.xml +++ b/reference/sdo_das_xml/reference.xml @@ -1,5 +1,5 @@ - + SDO XML Data Access Service Functions @@ -23,18 +23,15 @@ 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 + 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 XML DAS currently supports reading/writing XML - to/from a file or an http URL (for example, to support RSS feeds). -
@@ -45,7 +42,7 @@ SDO to have been installed. See the SDO installation instructions - for steps on how to do this. + for the details of how to do this.
@@ -246,36 +243,54 @@ The following examples are based on the letter example described in the - SDO documentation - . + 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 - . + letter.xml. + These two files are reproduced here: + + + + + + + + + + + + + +]]> + + + + + March 1, 2005 + Mutual of Omaha + Wild Kingdom, USA + Dear + Casy + Crocodile + Please buy more shark repellent. + Your premium is past due. + +]]> + + + - Working with the SDO_DAS_XML Class + Loading, altering, and saving an XML document - The following example shows how to create a SDO_DAS_XML Object and - use it to load an instance document. - The SDO_DAS_XML 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_DAS_XML 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 following example shows how an XML document can be loaded from a file, + altered, and written back. ]]> - - - Working with the SDO_DAS_XML Class - The above example shown, how to use the SDO_DAS_XML 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(( - company.xsd - )) as defined in SDO samples section. + An instance of the XML DAS is first obtained from the + SDO_DAS_XML::create + method, + which is a static method of the + SDO_DAS_XML + class. + The location of the xsd is passed as a parameter. + Once we have an instance of the XML DAS initialised + with a given schema, + we can use it to load the instance document using the + loadFromFile + method. + There is also a + loadFromString + method if you want to load an XML + instance document from a string. + If the instance document loads successfully, + you will be returned an object of type + SDO_DAS_XML_Document, + on which you can call the + getRootDataObject + method to get the SDO data object which is the root + of the SDO data graph. + You can then use SDO operations to change the graph. + In this example we alter the + date, + firstName, and + lastName properties. + Then we use the + saveDocumentToFile + method to write the changed document back to the file system. - + + This will write the following to letter-out.xml. + + createDataObject("companyNS", "CompanyType"); -$do->name = "Acme Inc"; -$dept1 = $do->createDataObject("departments"); -$dept1->name = "sales"; -$emp1 = $dept1->createDataObject("employees"); -$emp1->name = "Fred"; -$emp1->manager = FALSE; -$dept2 = $do->createDataObject("departments"); -$emp2 = $dept2->createDataObject("employees"); -$emp2->name = "Neil"; -$emp2->manager = TRUE; -print($xmldas->saveDataObjectToString($do, "companyNS", "CompanyType")); -var_dump($do); -?> + + + September 03, 2004 + Mutual of Omaha + Wild Kingdom, USA + Dear + Anantoju + Madhu + Please buy more shark repellent. + Your premium is past due. + ]]> - + + - - Working with the SDO_DAS_XML Class + Creating a new XML document - This example shows you how to create the DataObject and use - the Sequence API ( + 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 - For more information on Sequence API + the Sequence API - ) to construct a letter containing unstructured text. + as well assignments to properties to construct the data graph. - + + + This will emit the following output (line breaks have been inserted for readability): + + + + +April 09, 2005 +Acme Inc. United Kingdom. +Dear +Tarun +Nayar +Please note that your order number 12345 has been +dispatched today. Thanks for your business with us. + +]]> + - Working with the SDO_DAS_XML_Document Class + Setting XML document properties - 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. + 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. loadFromFile("letter.xml"); - print("Encoding is set to : " . $xdoc->getEncoding()); - print("XML Version : " . $xdoc->getXMLVersion(); + print("Encoding is set to : " . $xdoc->getEncoding() . "\n"); + print("XML Version : " . $xdoc->getXMLVersion() . "\n"); $xdoc->setXMLVersion("1.1"); print($xmldas->saveDocumentToString($xdoc)); } catch (SDO_TypeNotFoundException $e) { @@ -398,6 +453,20 @@ try { ?> ]]> + + 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. + + + +... +]]> + + @@ -648,6 +717,41 @@ try { &reference.sdo-das-xml.functions;
+ +