cvs: presentations /slides/php5xml2 WhoisData.wsdl boxing.jpg buzzword.gif choices.jpg confused.gif dom.xml dom_access.php dom_access.xml
dom_access2.php dom_access2.xml dom_access3.php dom_access3.xml dom_create.php dom_create.xml dom_html.php dom_html.xml dom_modify.php dom_modify.xml
dom_validate.php dom_validate.xml dom_validate2.xml dom_xpath.php dom_xpath.xml expat.php expat_callback.inc.php expat_struct.php extension.jpg
gears.gif imperfect.jpg libs.xml parsing_xml.xml php_xml.xml php_xml2.xml reader.jpg sax.xml sax2.xml sax3.xml simplexml.php simplexml.xml
simplexml_dom.php simplexml_dom.xml simplexml_ex.xml simplexml_mod.php simplexml_mod.xml simplexml_prob.php simplexml_problem.xml simplexml_xpath.php
simplexml_xpath.xml soap.gif soap.xml soap_client.php soap_client.xml soap_cons_pros.xml soap_doc.xml soap_doc_ex.xml soap_fault_ex.xml
soap_server.php soap_server.xml soap_wdsl_client.php soap_wsdl.xml thankyou.xml thedata.php thedata.xml titlepage.xml transformer.gif whatis.xml
whyxml.xml wizardry.jpg writer.gif wsdl.php xml.xml xmlread.php xmlread_valid1.php xmlreader.xml xmlreader_ex.xml xmlreader_sum.xml
xmlreader_validation.xml xmlreader_vs_sax.xml xmlrpc.jpg xmlrpc.xml xmlrpc_client.php xmlrpc_client.xml xmlrpc_cons_pros.xml xmlrpc_request.xml
xmlrpc_response.xml xmlrpc_server.php xmlrpc_server.xml xmlwrite.php xmlwrite2.php xmlwrite3.php xmlwriter.xml xmlwriter_ex.xml xmlwriter_ex2.xml
xmlwriter_ex3.xml xmlwriter_sum.xml xpath.jpg xpath.xml xslt.php xslt.xml xslt_ex.xml xslt_stylesheet.xml

From: Date: Mon, 16 May 2005 23:53:58 +0000
Subject: cvs: presentations /slides/php5xml2 WhoisData.wsdl boxing.jpg buzzword.gif choices.jpg confused.gif dom.xml dom_access.php dom_access.xml
dom_access2.php dom_access2.xml dom_access3.php dom_access3.xml dom_create.php dom_create.xml dom_html.php dom_html.xml dom_modify.php dom_modify.xml
dom_validate.php dom_validate.xml dom_validate2.xml dom_xpath.php dom_xpath.xml expat.php expat_callback.inc.php expat_struct.php extension.jpg
gears.gif imperfect.jpg libs.xml parsing_xml.xml php_xml.xml php_xml2.xml reader.jpg sax.xml sax2.xml sax3.xml simplexml.php simplexml.xml
simplexml_dom.php simplexml_dom.xml simplexml_ex.xml simplexml_mod.php simplexml_mod.xml simplexml_prob.php simplexml_problem.xml simplexml_xpath.php
simplexml_xpath.xml soap.gif soap.xml soap_client.php soap_client.xml soap_cons_pros.xml soap_doc.xml soap_doc_ex.xml soap_fault_ex.xml
soap_server.php soap_server.xml soap_wdsl_client.php soap_wsdl.xml thankyou.xml thedata.php thedata.xml titlepage.xml transformer.gif whatis.xml
whyxml.xml wizardry.jpg writer.gif wsdl.php xml.xml xmlread.php xmlread_valid1.php xmlreader.xml xmlreader_ex.xml xmlreader_sum.xml
xmlreader_validation.xml xmlreader_vs_sax.xml xmlrpc.jpg xmlrpc.xml xmlrpc_client.php xmlrpc_client.xml xmlrpc_cons_pros.xml xmlrpc_request.xml
xmlrpc_response.xml xmlrpc_server.php xmlrpc_server.xml xmlwrite.php xmlwrite2.php xmlwrite3.php xmlwriter.xml xmlwriter_ex.xml xmlwriter_ex2.xml
xmlwriter_ex3.xml xmlwriter_sum.xml xpath.jpg xpath.xml xslt.php xslt.xml xslt_ex.xml xslt_stylesheet.xml
Groups: php.pres 
Request: Send a blank email to pres+get-1136@lists.php.net to get a copy of this message
iliaa Mon May 16 19:53:58 2005 EDT Added files: /presentations/slides/php5xml2 WhoisData.wsdl boxing.jpg buzzword.gif choices.jpg confused.gif dom.xml dom_access.php dom_access.xml dom_access2.php dom_access2.xml dom_access3.php dom_access3.xml dom_create.php dom_create.xml dom_html.php dom_html.xml dom_modify.php dom_modify.xml dom_validate.php dom_validate.xml dom_validate2.xml dom_xpath.php dom_xpath.xml expat.php expat_callback.inc.php expat_struct.php extension.jpg gears.gif imperfect.jpg libs.xml parsing_xml.xml php_xml.xml php_xml2.xml reader.jpg sax.xml sax2.xml sax3.xml simplexml.php simplexml.xml simplexml_dom.php simplexml_dom.xml simplexml_ex.xml simplexml_mod.php simplexml_mod.xml simplexml_prob.php simplexml_problem.xml simplexml_xpath.php simplexml_xpath.xml soap.gif soap.xml soap_client.php soap_client.xml soap_cons_pros.xml soap_doc.xml soap_doc_ex.xml soap_fault_ex.xml soap_server.php soap_server.xml soap_wdsl_client.php soap_wsdl.xml thankyou.xml thedata.php thedata.xml titlepage.xml transformer.gif whatis.xml whyxml.xml wizardry.jpg writer.gif wsdl.php xml.xml xmlread.php xmlread_valid1.php xmlreader.xml xmlreader_ex.xml xmlreader_sum.xml xmlreader_validation.xml xmlreader_vs_sax.xml xmlrpc.jpg xmlrpc.xml xmlrpc_client.php xmlrpc_client.xml xmlrpc_cons_pros.xml xmlrpc_request.xml xmlrpc_response.xml xmlrpc_server.php xmlrpc_server.xml xmlwrite.php xmlwrite2.php xmlwrite3.php xmlwriter.xml xmlwriter_ex.xml xmlwriter_ex2.xml xmlwriter_ex3.xml xmlwriter_sum.xml xpath.jpg xpath.xml xslt.php xslt.xml xslt_ex.xml xslt_stylesheet.xml Log: Vancounver PHP5/XML talk.

http://cvs.php.net/co.php/presentations/slides/php5xml2/WhoisData.wsdl?r=1.1&p=1 Index: presentations/slides/php5xml2/WhoisData.wsdl +++ presentations/slides/php5xml2/WhoisData.wsdl <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="urn:whoisDataService.whois.comms.ws.dsdata.co.uk" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:intf="urn:whoisDataService.whois.comms.ws.dsdata.co.uk" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="urn:whoisDataService.whois.comms.ws.dsdata.co.uk" xmlns="http://schemas.xmlsoap.org/wsdl/"> <wsdl:types> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:whoisDataService.whois.comms.ws.dsdata.co.uk"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="WhoisRequest"> <sequence> <element name="domain" nillable="true" type="xsd:string"/> <element name="clientID" nillable="true" type="xsd:string"/> <element name="emailAddress" nillable="true" type="xsd:string"/> </sequence> </complexType> <element name="WhoisRequest" nillable="true" type="impl:WhoisRequest"/> <complexType name="WhoisResult"> <sequence> <element name="result" type="xsd:int"/> <element name="resultDescription" nillable="true" type="xsd:string"/> <element name="server" nillable="true" type="xsd:string"/> <element name="domainName" nillable="true" type="xsd:string"/> <element name="resultText" nillable="true" type="xsd:string"/> <element name="registrar" nillable="true" type="xsd:string"/> <element name="registrarURL" nillable="true" type="xsd:string"/> <element name="registrant" nillable="true" type="xsd:string"/> <element name="status" nillable="true" type="xsd:string"/> <element name="nameServers" nillable="true" type="xsd:string"/> <element name="registrantAddress" nillable="true" type="xsd:string"/> <element name="country" nillable="true" type="xsd:string"/> <element name="updatedOn" nillable="true" type="xsd:dateTime"/> <element name="createdOn" nillable="true" type="xsd:dateTime"/> <element name="expiresOn" nillable="true" type="xsd:dateTime"/> </sequence> </complexType> <complexType name="ArrayOfWhoisResult"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="impl:WhoisResult[]"/> </restriction> </complexContent> </complexType> <element name="ArrayOfWhoisResult" nillable="true" type="impl:ArrayOfWhoisResult"/> </schema> </wsdl:types> <wsdl:message name="getWhoisDataResponse"> <wsdl:part name="getWhoisDataReturn" type="intf:ArrayOfWhoisResult"/> </wsdl:message> <wsdl:message name="getWhoisDataRequest"> <wsdl:part name="in0" type="intf:WhoisRequest"/> </wsdl:message> <wsdl:portType name="WhoisData"> <wsdl:operation name="getWhoisData" parameterOrder="in0"> <wsdl:input name="getWhoisDataRequest" message="intf:getWhoisDataRequest"/> <wsdl:output name="getWhoisDataResponse" message="intf:getWhoisDataResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="WhoisDataSoapBinding" type="intf:WhoisData"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getWhoisData"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="getWhoisDataRequest"> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:whoisDataService.whois.comms.ws.dsdata.co.uk"/> </wsdl:input> <wsdl:output name="getWhoisDataResponse"> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:whoisDataService.whois.comms.ws.dsdata.co.uk"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="WhoisDataService"> <wsdl:port name="WhoisData" binding="intf:WhoisDataSoapBinding"> <wsdlsoap:address location="http://wavendon.dsdata.co.uk/axis/services/WhoisData"/> </wsdl:port> </wsdl:service> </wsdl:definitions> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom.xml +++ presentations/slides/php5xml2/dom.xml <slide title="DOM Extension"> <blurb fontsize="3.5em"> DOM is not DOMXML. DOM extension has been written from scratch and strongly relies on the PHP 5 features &amp; capabilities. |FF0000|DOM is not compatible with DOMXML| </blurb> <list title="Features" fontsize="2.5em"> <bullet>DOM Level 3 Load and Save Support</bullet> <bullet>XPath</bullet> <bullet>Validation support</bullet> <bullet>NamedNodeMap support</bullet> <bullet>Complete Namespaces support</bullet> <bullet>Interop with SimpleXML and XSLT</bullet> <bullet>HTML</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_access.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_access.php +++ presentations/slides/php5xml2/dom_access.php <?php $dom = new domDocument(); // create a DOM object $dom->load(dirname(__FILE__) . "/thedata.xml"); // load data from XML file /* access elements by tag name */ foreach ($dom->getElementsByTagName('title') as $node) { echo $node->nodeValue . "<br />"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_access.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_access.xml +++ presentations/slides/php5xml2/dom_access.xml <slide title="Accessing Nodes w/DOM"> <example filename="dom_access.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_access2.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_access2.php +++ presentations/slides/php5xml2/dom_access2.php <?php $xmlstring = '<?xml version="1.0" ?> <!DOCTYPE books [ <!ATTLIST book id ID #IMPLIED> ]> <books> <book id="1"> <title>Book 1</title> </book> <book id="2"> <title>Book 2</title> </book> </books>'; $dom = new domDocument(); /* load XML from string */ $dom->loadXML($xmlstring); /* get the node identified by id #2 */ $node = $dom->getElementById("2"); print trim($node->nodeValue); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_access2.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_access2.xml +++ presentations/slides/php5xml2/dom_access2.xml <slide title="Accessing Nodes w/DOM"> <example filename="dom_access2.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_access3.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_access3.php +++ presentations/slides/php5xml2/dom_access3.php <?php $dom = new domDocument(); $dom->load(dirname(__FILE__) . "/thedata.xml"); $root = $dom->documentElement; // <forum> foreach ($root->childNodes as $child) { if ($child->nodeType == XML_ELEMENT_NODE) { // <item> $id = $child->getAttribute("id"); // <item id="value"> echo "item #{$id}<br />"; foreach ($child->childNodes as $c2) { // item nodes if ($c2->nodeType == XML_ELEMENT_NODE) { // <title>, <link> echo "{$c2->nodeName} => {$c2->nodeValue}<br />"; } } } } ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_access3.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_access3.xml +++ presentations/slides/php5xml2/dom_access3.xml <slide title="DOM Tree"> <example filename="dom_access3.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_create.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_create.php +++ presentations/slides/php5xml2/dom_create.php <?php $dom = new domDocument('1.0'); $root = $dom->createElement('root'); // create new element foreach (array('foo', 'bar', 'baz') as $v) { $node = $dom->createElement($v); // create new sub-element $node->appendChild($dom->createTextNode($v)); // add value to element $root->appendChild($node); // append sub-element to root element } $dom->appendChild($root); // add root node to document $xml = $dom->saveXML(); // output XML echo nl2br(htmlspecialchars(str_replace('><', ">\n<", $xml))); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_create.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_create.xml +++ presentations/slides/php5xml2/dom_create.xml <slide title="Creating XML with DOM"> <example filename="dom_create.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_html.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_html.php +++ presentations/slides/php5xml2/dom_html.php <?php $dom = new DomDocument(); /* load HTML document (if it is not valid) */ @$dom->loadHTMLFile("http://" . $_SERVER['SERVER_ADDR'] . dirname($_SERVER['PHP_SELF']) . '/1'); $xp = new DomXpath($dom); /* use XPath to get the title of the */ $res = $xp->query("//title/text()"); echo $res->item(0)->nodeValue; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_html.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_html.xml +++ presentations/slides/php5xml2/dom_html.xml <slide title="DOM and HTML"> <example filename="dom_html.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_modify.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_modify.php +++ presentations/slides/php5xml2/dom_modify.php <?php $dom = new domDocument('1.0'); $dom->load(dirname(__FILE__) . "/thedata.xml"); $new_item = $dom->createElement('item'); $new_item->setAttribute("id", 1234); // set attribute id for new item foreach (array('title', 'link', 'description') as $v) { $node = $dom->createElement($v); $node->appendChild($dom->createTextNode($v)); $new_item->appendChild($node); } // append entry to existing forum entries $dom->documentElement->appendChild($new_item); $xml = $dom->saveXML(); echo nl2br(htmlspecialchars(str_replace('><', ">\n<", $xml))); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_modify.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_modify.xml +++ presentations/slides/php5xml2/dom_modify.xml <slide title="Modify XML with DOM"> <example filename="dom_modify.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_validate.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_validate.php +++ presentations/slides/php5xml2/dom_validate.php <?php $dom = new domDocument; $dom->load(dirname(__FILE__) . "/thedata.xml"); if (@$dom->validate()) { echo "Document is valid"; } else { echo "Document is invalid"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_validate.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_validate.xml +++ presentations/slides/php5xml2/dom_validate.xml <slide title="DOM &amp; XML Validation"> <example filename="dom_validate.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_validate2.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_validate2.xml +++ presentations/slides/php5xml2/dom_validate2.xml <slide title="DOM &amp; XML Validation"> <list fontsize="3.5em" title="DOM XML Validation Mechanisms"> <bullet>boolean attribute DOMDocument->validateOnParse</bullet> <bullet>boolean DOMDocument->validate()</bullet> <bullet>boolean DOMDocument->schemaValidate(string filename)</bullet> <bullet>boolean DOMDocument->schemaValidateSource(string xml)</bullet> <bullet>boolean DOMDocument->relaxNGValidate(string filename)</bullet> <bullet>boolean DOMDocument->relaxNGValidateSource(string xml)</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_xpath.php?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_xpath.php +++ presentations/slides/php5xml2/dom_xpath.php <?php $dom = new domDocument(); $data = file_get_contents(dirname(__FILE__) . "/thedata.xml"); $dom->loadXML($data); // load data from XML string $xp = new DomXPath($dom); // create XPath object $res = $xp->query("//item/title"); // get title element echo $res->item(0)->nodeValue; // get data from 1st entry ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/dom_xpath.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/dom_xpath.xml +++ presentations/slides/php5xml2/dom_xpath.xml <slide title="DOM &amp; XPath"> <example filename="dom_xpath.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/expat.php?r=1.1&p=1 Index: presentations/slides/php5xml2/expat.php +++ presentations/slides/php5xml2/expat.php <?php // Evil pres2 hackery $path = dirname(__FILE__); include("{$path}/expat_callback.inc.php"); $x = xml_parser_create(); // tag handler xml_set_element_handler($x, 'w_start_tag', 'w_end_tag'); // data handler xml_set_character_data_handler($x, 'w_data'); // always make tag names uppercase xml_parser_set_option($x, XML_OPTION_CASE_FOLDING, TRUE); // parse xml file xml_parse($x, file_get_contents("{$path}/thedata.xml")); // free memory xml_parser_free($x); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/expat_callback.inc.php?r=1.1&p=1 Index: presentations/slides/php5xml2/expat_callback.inc.php +++ presentations/slides/php5xml2/expat_callback.inc.php <?php class entry { public $title, $id, $link, $description; // temporary variable used to indicate current tag public $cur_tag; } function w_start_tag($x, $tag, $attr) { global $w; switch ($tag) { case 'ITEM': $w = new entry; $w->id = $attr['ID']; break; case 'TITLE': case 'LINK': case 'DESCRIPTION': $w->cur_tag = $tag; break; } } function w_end_tag($x, $tag) { global $w; if ($tag == 'DESCRIPTION') { echo "Title: <a href='{$w->link}'>{$w->title}</a><br />\n Body: {$w->description}<hr />"; unset($w); } } function w_data($x, $data) { global $w; // move along, nothing to see here if (!is_object($w)) return; switch ($w->cur_tag) { case 'TITLE': case 'LINK': case 'DESCRIPTION': $w->{strtolower($w->cur_tag)} .= trim($data); break; } } ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/expat_struct.php?r=1.1&p=1 Index: presentations/slides/php5xml2/expat_struct.php +++ presentations/slides/php5xml2/expat_struct.php <?php $x = xml_parser_create(); // uppercase xml elements xml_parser_set_option($x, XML_OPTION_CASE_FOLDING, TRUE); // spaces begone!! xml_parser_set_option($x, XML_OPTION_SKIP_WHITE, TRUE); $data = file_get_contents(dirname(__FILE__) . '/thedata.xml'); xml_parse_into_struct($x, $data, $forum, $tags); xml_parser_free($x); // Woohooo, we're done! // count number of instances of a particular property to // determine the number of entries inside the XML file $num_elements = count($tags['DESCRIPTION']); for($i = 0; $i < $num_elements; $i++) { $title = $forum[$tags['TITLE'][$i]]['value']; $body = $forum[$tags['DESCRIPTION'][$i]]['value']; $link = $forum[$tags['LINK'][$i]]['value']; echo "Title: <a href='{$link}'>{$title}</a><br /> Body: {$body}<hr />"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/libs.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/libs.xml +++ presentations/slides/php5xml2/libs.xml <slide title="LibXML2 vs Expat"> <blurb> Aside from the addition of the new XML parsing extensions, in PHP 5 the underlying XML library was changed as well. </blurb> <list title="LibXML2 the Good"> <bullet>Feature complete</bullet> <bullet>Active development</bullet> <bullet>Very fast for DOM</bullet> </list> <list title="and the Bad"> <bullet>Significantly larger then Expat (not bundled with PHP)</bullet> <bullet>Slightly slower for SAX</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/parsing_xml.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/parsing_xml.xml +++ presentations/slides/php5xml2/parsing_xml.xml <slide> <title>XML Processing</title> <image filename="gears.gif" align="center" /> <blurb><![CDATA[ <table class="index" border="0" cellpadding=5 align="center" > <tr> <th width="50%" align="left" style="font-size: 2em;">DOM</th> <th width="50%" align="left" style="font-size: 2em;">SAX</th> </tr> <tr> <td style="font-size: 1.8em; color: blue;">Good for small documents</td> <td style="font-size: 1.8em; color: green;">Event driven, good for large documents</td> <tr> <tr> <td style="font-size: 1.8em; color: blue;">Simpler to use (less code)</td> <td style="font-size: 1.8em; color: green;">More memory efficient (if dom tree is not built)</td> <tr> <tr> <td style="font-size: 1.8em; color: blue;">Easier to generate XML</td> <td style="font-size: 1.8em; color: green;">Faster for remote sources.</td> </tr> </table> ]]></blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/php_xml.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/php_xml.xml +++ presentations/slides/php5xml2/php_xml.xml <slide> <title>PHP 5 and XML</title> <image filename="choices.jpg" align="right" /> <blurb> In PHP 5 working with XML can be done in any number of ways, via a whole series of extensions. </blurb> <list> <bullet>XML extension</bullet> <bullet>DOM</bullet> <bullet>XML-RPC</bullet> <bullet>Simplexml</bullet> <bullet>SOAP</bullet> <bullet>XML Reader (PECL)</bullet> <bullet>XML Writer (PECL)</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/php_xml2.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/php_xml2.xml +++ presentations/slides/php5xml2/php_xml2.xml <slide title="Extension Functionality"> <blurb> The PHP's XML extensions can be split into 4 categories, based on their functionality and backend processing mechanisms. </blurb> <image filename="extension.jpg" align="right" /> <list title="Document Object Model (DOM)" fontsize="2em"> <bullet>SimpleXML</bullet> <bullet>DOM |00AA00|Evolution of domxml in PHP 4|</bullet> </list> <list title="Simple API for XML (SAX)" fontsize="2em"> <bullet>XML |00AA00|Same as in PHP 4|</bullet> <bullet>XMLReader/XMLWriter</bullet> </list> <list title="Web Services" fontsize="2em"> <bullet>SOAP</bullet> <bullet>XML-RPC |00AA00|Same as in PHP 4|</bullet> </list> <list title="XML Transformation" fontsize="2em"> <bullet>XSL |00AA00|Evolution of XLST in PHP 4|</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/sax.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/sax.xml +++ presentations/slides/php5xml2/sax.xml <slide> <title>SAX Callbacks</title> <example filename="expat_callback.inc.php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/sax2.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/sax2.xml +++ presentations/slides/php5xml2/sax2.xml <slide> <title>SAX Glue</title> <example filename="expat.php" fontsize="1.4em" /> <blurb> End Result: </blurb> <example filename="expat.php" hide="1" result="1" type="html" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/sax3.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/sax3.xml +++ presentations/slides/php5xml2/sax3.xml <slide> <title>SAX Structured Access</title> <blurb> A simpler way to access XML structures (SAX for lazy people). <![CDATA[<br />]]>This is pretty much a DOM emulation mode. </blurb> <example filename="expat_struct.php" result="1" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml.php?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml.php +++ presentations/slides/php5xml2/simplexml.php <?php /* load a xml file to memory & parse it */ $xml = simplexml_load_file(dirname(__FILE__) . '/thedata.xml'); /* We are done, output time */ foreach ($xml->item as $msg) { echo "Title: <a href='{$msg->link}'>{$msg->title}</a> (id: {$msg['id']}) <br />Body: {$msg->description}<hr />"; } ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml.xml +++ presentations/slides/php5xml2/simplexml.xml <slide title="SimpleXML"> <image filename="wizardry.jpg" align="right" /> <blurb fontsize="3em"> Sterling Hughes: "XML is the solution to all your problems; SimpleXML ensures it isn't the root of your problems!" </blurb> <list fontsize="2.5em"> <bullet>New in PHP 5 (enabled by default)</bullet> <bullet>Object Oriented approach to XML Documents</bullet> <bullet>Really useful for well structured XML</bullet> <bullet>Supports XPath for all sorts of tricks</bullet> <bullet>Can write to attributes</bullet> <bullet>|FF0000|Fast and Simple to use|</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_dom.php?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_dom.php +++ presentations/slides/php5xml2/simplexml_dom.php <?php $xml = simplexml_load_file(dirname(__FILE__) . '/thedata.xml'); /* convert SimpleXML to DOM object */ $dom = dom_import_simplexml($xml); /* convert from DOM object back to SimpleXML */ $xml2 = simplexml_import_dom($dom); /* confirm that no data was lost */ echo ($xml2->asXML() == $xml->asXML()); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_dom.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_dom.xml +++ presentations/slides/php5xml2/simplexml_dom.xml <slide title="SimpleXML &amp; DOM"> <example filename="simplexml_dom.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_ex.xml +++ presentations/slides/php5xml2/simplexml_ex.xml <slide title="SimpleXML in Action"> <example filename="simplexml.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_mod.php?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_mod.php +++ presentations/slides/php5xml2/simplexml_mod.php <?php $xml = simplexml_load_file(dirname(__FILE__) . '/thedata.xml'); /* modify all item ids and titles */ foreach ($xml->item as $msg) { $msg['id'] += 1000; // increase id by 1000 $msg->title .= ' ( was modified ) '; // indicate that data was changed } /* output modified XML document */ echo '<pre>' . htmlspecialchars($xml->asXML()) . '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_mod.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_mod.xml +++ presentations/slides/php5xml2/simplexml_mod.xml <slide title="SimpleXML Basic Mods."> <example filename="simplexml_mod.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_prob.php?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_prob.php +++ presentations/slides/php5xml2/simplexml_prob.php <?php $html = '<html><body>Some random <strong>Bold</strong> and <em>italics</em> text.</body></html>'; $xml = simplexml_load_string($html); echo $xml->body . "<br />"; echo $xml->body->strong . "<br />"; echo $xml->body->em . "<br />"; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_problem.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_problem.xml +++ presentations/slides/php5xml2/simplexml_problem.xml <slide title="SimpleXML is not Perfect"> <image filename="imperfect.jpg" align="right" /> <break /> <example filename="simplexml_prob.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_xpath.php?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_xpath.php +++ presentations/slides/php5xml2/simplexml_xpath.php <?php /* load XML document from a string */ $xml = simplexml_load_string(file_get_contents(dirname(__FILE__) . '/thedata.xml')); /* access the 1st <title> from the document */ echo array_shift($xml->xpath("//item[1]/title")) . "<br />"; /* get data from item entry with an id of 10149 */ echo '<pre>'; print_r($xml->xpath("//item[@id=10149]")); echo '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/simplexml_xpath.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/simplexml_xpath.xml +++ presentations/slides/php5xml2/simplexml_xpath.xml <slide title="SimpleXML &amp; XPath"> <example filename="simplexml_xpath.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap.xml +++ presentations/slides/php5xml2/soap.xml <slide title="SOAP"> <blurb fontsize="4em">The road to hell is paved with good intentions.</blurb> <image filename="soap.gif" align="right" /> <list> <bullet>Formerly known as Simple Object Access Protocol.</bullet> <bullet>A messaging format primary used for RPC.</bullet> <bullet>Uses XML.</bullet> <bullet>View Source protocol.</bullet> </list> <list title="Brief History"> <bullet>Initial release, Babylon 2800 B.C</bullet> <bullet>SOAP 1.0, Microsoft 1999</bullet> <bullet>SOAP 1.1, IBM and Microsoft 2000</bullet> <bullet>SOAP 1.2, W3C present time</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_client.php?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_client.php +++ presentations/slides/php5xml2/soap_client.php <?php $client = new SoapObject("http://example.com/server.php", "urn:Object"); echo $client->ls("/vmlinuz*"); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_client.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_client.xml +++ presentations/slides/php5xml2/soap_client.xml <slide title="SOAP WSDL Client"> <example filename="soap_wdsl_client.php" hide="0" result="0" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_cons_pros.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_cons_pros.xml +++ presentations/slides/php5xml2/soap_cons_pros.xml <slide title="SOAP Summary"> <list fontsize="4em" title="Advantages"> <bullet>PHP API is very easy to use</bullet> <bullet>Ability to customize every portion of the message</bullet> <bullet>Fully Buzzword Compliant</bullet> </list> <list fontsize="4em" title="Disadvantages"> <bullet>Not yet completely stable</bullet> <bullet>Difficult to understand internals</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_doc.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_doc.xml +++ presentations/slides/php5xml2/soap_doc.xml <slide title="SOAP Document Rules"> <blurb fontsize="4.0em"> A SOAP Document must meet the following requirements </blurb> <list fontsize="4.0em"> <bullet>Must have a top-level %Envelope% namespaced to %http://schemas.xmlsoap.org/soap/envelope/%</bullet> <bullet>Must contain %Body% element</bullet> <bullet>May contain an optional %Header% and %Fault% elements</bullet> <bullet>The contents of %Header% and %Body% must be properly namespaced</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_doc_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_doc_ex.xml +++ presentations/slides/php5xml2/soap_doc_ex.xml <slide title="SOAP Document"> <example title="SOAP Document"><![CDATA[<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Header> <m:Trans xmlns:m="http://www.example.com/header/" soap:mustUnderstand="1"> 234 </m:Trans> </soap:Header> <soap:Body> <soap:Fault> </soap:Fault> <purge xmlns="http://fud.prohost.org/message"> <documentid>298</documentid> </purge> </soap:Body> </soap:Envelope>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_fault_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_fault_ex.xml +++ presentations/slides/php5xml2/soap_fault_ex.xml <slide title="SOAP Fault"> <example><![CDATA[<?xml version="1.0"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:m="http://www.example.org/timeouts" xmlns:xml="http://www.w3.org/XML/1998/namespace"> <env:Body> <env:Fault> <env:Code> <env:Value>env:Sender</env:Value> <env:Subcode> <env:Value>m:MessageTimeout</env:Value> </env:Subcode> </env:Code> <env:Reason> <env:Text xml:lang="en">Sender Timeout</env:Text> </env:Reason> <env:Detail> <m:MaxTime>P5M</m:MaxTime> </env:Detail> </env:Fault> </env:Body> </env:Envelope>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_server.php?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_server.php +++ presentations/slides/php5xml2/soap_server.php <?php class filesystem { function ls($dir) { return shell_exec("ls ".escapeshellarg($dir)); } } // SOAP $server = new SoapServer("urn:Object"); $server->setClass('filesystem'); $server->handle(); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_server.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_server.xml +++ presentations/slides/php5xml2/soap_server.xml <slide title="SOAP Server/Client"> <example filename="soap_server.php" fontsize="1.4em" title="SOAP Server" /> <example filename="soap_client.php" fontsize="1.4em" title="SOAP Client" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_wdsl_client.php?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_wdsl_client.php +++ presentations/slides/php5xml2/soap_wdsl_client.php <?php /* create a new SOAP client based on given wsdl file */ $client = new SoapClient("WhoisData.wsdl"); /* run a whois query by calling getWhoisData method provided by * whois server and described by WhoisData.wsdl */ $result = $client->getWhoisData( /* create parameters needed for the request */ new SoapParam("php.net", "domain"), new SoapParam("1234", "clientID"), new SoapParam("emailAddress", "user@domain.com") ); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/soap_wsdl.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/soap_wsdl.xml +++ presentations/slides/php5xml2/soap_wsdl.xml <slide title="WSDL"> <blurb fontsize="3em" title="Web Service Description Language (WSDL)"> Machine readable description (XML) of a web service. Used here to define server's methods and parameters. </blurb> <example filename="wsdl.php" hide="1" result="1" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/thankyou.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/thankyou.xml +++ presentations/slides/php5xml2/thankyou.xml <slide title="Thank You!" fontsize="6em"> <blurb title="Find more information online..." /> <break /> <link marginleft="2em" leader="SimpleXML Docs : ">http://www.php.net/simplexml</link> <link marginleft="2em" leader="DOM Docs : ">http://www.php.net/dom</link> <link marginleft="2em" leader="XSL Docs : ">http://www.php.net/xsl</link> <link marginleft="2em" leader="SOAP Docs : ">http://www.php.net/soap</link> <break lines="2" /> <blurb title="Contact Me" /> <link fontsize="2.5em" marginleft="2em" leader="Ilia Alshanetsky ">ilia@php.net</link> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/thedata.php?r=1.1&p=1 Index: presentations/slides/php5xml2/thedata.php +++ presentations/slides/php5xml2/thedata.php <?php echo '<pre>' . htmlspecialchars(' <forum uri="http://fud.prohost.org/forum/index.php"> <item id="10084"> <title>Binary Protocols vs XML</title> <link>http://fud.prohost.org/forum/index.php/m/10084</link> <description>Why does everyone insist on using XML?</description> </item> <item id="10149"> <title>How do I post messages?</title> <link>http://fud.prohost.org/forum/index.php/m/10149</link> <description>I can post messages, help!</description> </item> </forum> ') . '</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/thedata.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/thedata.xml +++ presentations/slides/php5xml2/thedata.xml <?xml version="1.0"?> <forum uri="http://fud.prohost.org/forum/index.php"> <item id="10084"> <title>Binary Protocols vs XML</title> <link>http://fud.prohost.org/forum/index.php/m/10084</link> <description>Why does everyone insist on using XML?</description> </item> <item id="10149"> <title>How do I post messages?</title> <link>http://fud.prohost.org/forum/index.php/m/10149</link> <description>I can post messages, help!</description> </item> </forum> http://cvs.php.net/co.php/presentations/slides/php5xml2/titlepage.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/titlepage.xml +++ presentations/slides/php5xml2/titlepage.xml <slide template="titlepage" fontsize="6em"> <title>Welcome!</title> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/whatis.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/whatis.xml +++ presentations/slides/php5xml2/whatis.xml <slide> <title>What is XML?</title> <blurb align="center" fontsize="6em"> What is XML? </blurb> <image filename="confused.gif" align="center" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/whyxml.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/whyxml.xml +++ presentations/slides/php5xml2/whyxml.xml <slide> <title>Why Use XML?</title> <blurb> There are a number of good reasons to use XML, however it is important to note that XML is not a "one size fit all" solution. </blurb> <image filename="buzzword.gif" align="right" /> <list> <bullet>Completely platform independent.</bullet> <bullet>Most languages can easily parse it.</bullet> <bullet>Fairly simple syntax.</bullet> <bullet>Not limited to a particular protocol.</bullet> <bullet>Unicode Support</bullet> <bullet>Buzzword compliance.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/wsdl.php?r=1.1&p=1 Index: presentations/slides/php5xml2/wsdl.php +++ presentations/slides/php5xml2/wsdl.php <pre> <?php echo htmlspecialchars(file_get_contents(dirname(__FILE__) . "/WhoisData.wsdl")); ?> </pre> http://cvs.php.net/co.php/presentations/slides/php5xml2/xml.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xml.xml +++ presentations/slides/php5xml2/xml.xml <slide> <title>What is XML?</title> <blurb> XML - eXtensible Markup Language - a structured way to present information. </blurb> <example filename="thedata.php" hide="1" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlread.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlread.php +++ presentations/slides/php5xml2/xmlread.php <?php // create XMLReader object $reader = new XMLReader(); // open XML file, to open strings use $reader->XML($string) $reader->open(dirname(__FILE__) . '/thedata.xml'); $id = $link = $description = $title = $curval = ''; // loop through the elements while ($reader->read()) { switch ($reader->nodeType) { case XMLREADER_ELEMENT: /* fetch element name */ $curval = $reader->localName; /* check for attributes */ if ($reader->hasAttributes) { /* move to 1st attribute */ $attr = $reader->moveToFirstAttribute(); while ($attr) { ${$reader->name} = $reader->value; /* move to next attribute */ $attr = $reader->moveToNextAttribute(); } } break; case XMLREADER_TEXT: /* fetch element value */ ${$curval} = $reader->value; break; case XMLREADER_END_ELEMENT: /* element end */ /* if end of <item>, print info */ if ($reader->localName == 'item') { echo "Title: <a href='{$link}'>{$title}</a><br /> Body: {$description}<hr />"; } break; } } ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlread_valid1.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlread_valid1.php +++ presentations/slides/php5xml2/xmlread_valid1.php <?php $reader = new XMLReader(); /* load xml document as a string */ $reader->XML(file_get_contents(dirname(__FILE__) . '/thedata.xml')); /* tell the parser to perform syntax validation */ $reader->setParserProperty(XMLREADER_VALIDATE, TRUE); // loop until end of document // @ blocks the parser errors (missing DTD in this case) while (@$reader->read()); echo "XML document is: " . ($reader->isValid() ? '' : ' not') . " valid."; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlreader.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlreader.xml +++ presentations/slides/php5xml2/xmlreader.xml <slide title="XmlReader"> <blurb fontsize="5em" align="center"> XmlReader </blurb> <image filename="reader.jpg" align="center" /> <list fontsize="3em"> <bullet>Very new extension (in PECL)</bullet> <bullet>a so called Pull Parser</bullet> <bullet>API derived from C# XmlTextReader</bullet> <bullet>A replacement for SAX</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlreader_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlreader_ex.xml +++ presentations/slides/php5xml2/xmlreader_ex.xml <slide title="XmlReader in Action"> <example filename="xmlread.php" hide="0" result="1" type="php" fontsize="2em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlreader_sum.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlreader_sum.xml +++ presentations/slides/php5xml2/xmlreader_sum.xml <slide title="XmlReader Summary"> <list fontsize="3em" title="XmlReader Summary"> <bullet>A replacement for SAX</bullet> <bullet>Support for XML &amp; RelaxNG Validation</bullet> <bullet>Simple and Proven API</bullet> <bullet>In most cases faster then SAX (XML extension)</bullet> <bullet>|FF0000|Very new &amp; Experimental|</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlreader_validation.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlreader_validation.xml +++ presentations/slides/php5xml2/xmlreader_validation.xml <slide title="XmlReader XML Validation"> <blurb> Aside from parsing XML documents, XmlReader can also be used to quickly validate them. </blurb> <example filename="xmlread_valid1.php" hide="0" result="1" type="php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlreader_vs_sax.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlreader_vs_sax.xml +++ presentations/slides/php5xml2/xmlreader_vs_sax.xml <slide title="XmlReader vs SAX"> <image filename="boxing.jpg" align="center" /> <list fontsize="3.5em"> <bullet>Sax is Event based</bullet> <bullet>XmlReader is cursor based</bullet> <bullet>XmlReader has support for namespaces, validation and entities</bullet> <bullet>Both do not load the whole document into memory</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc.xml +++ presentations/slides/php5xml2/xmlrpc.xml <slide title="XMLRPC"> <break /> <blurb fontsize="3em"> XMLRPC allows a computer to execute functions and class methods on another computer with any given arguments. </blurb> <image filename="xmlrpc.jpg" align="center" /> <blurb fontsize="3em"> Primarily uses HTTP for transporting requests that are encoded using XML. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc_client.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc_client.php +++ presentations/slides/php5xml2/xmlrpc_client.php <?php // generate request $request = xmlrpc_encode_request("ls", array("-1", "--color=no", dirname(__FILE__))); // we encode the request to make it safe to pass via GET $request = base64_encode($request); // pres2 hackery $url = preg_replace("!.*/presentations/!", "/presentations/", __FILE__); $url = str_replace('xmlrpc_client.php', 'xmlrpc_server.php', $url); // we now need to submit the request to the server $response = file_get_contents("http://{$_SERVER['HTTP_HOST']}{$url}?query={$request}"); // decode XML response into something PHP can understand $response = xmlrpc_decode($response); echo nl2br($response); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc_client.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc_client.xml +++ presentations/slides/php5xml2/xmlrpc_client.xml <slide title="XMLRPC Client"> <example filename="xmlrpc_client.php" result="0" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc_cons_pros.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc_cons_pros.xml +++ presentations/slides/php5xml2/xmlrpc_cons_pros.xml <slide title="XMLRPC Cons &amp; Pros"> <list title="Why use XMLRPC?"> <bullet>Easy to understand, implement and debug</bullet> <bullet>Quite fast</bullet> <bullet>Stable</bullet> <bullet>Can be emulated with PEAR</bullet> </list> <list title="XML-RPC sucks because..."> <bullet>No new functionality being added</bullet> <bullet>Not completely buzzword compliant</bullet> <bullet>Very few big providers use XMLRPC</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc_request.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc_request.xml +++ presentations/slides/php5xml2/xmlrpc_request.xml <slide title="XMLRPC Request Source"> <example title="Request"><![CDATA[<?xml version="1.0"?> <methodCall> <methodName>package.info</methodName> <params> <param> <value> <string>XML_RPC</string> </value> </param> </params> </methodCall>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc_response.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc_response.xml +++ presentations/slides/php5xml2/xmlrpc_response.xml <slide title="XMLRPC Response Source"> <example title="Response"><![CDATA[<?xml version="1.0" encoding="iso-8859-1"?> <methodResponse> <params> <param> <value> <struct> <member> <name>packageid</name> <value> <string>17</string> </value> </member> <member> <name>name</name> <value> <string>XML_RPC</string> </value> </member> </struct> </value> </param> </params> </methodResponse>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc_server.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc_server.php +++ presentations/slides/php5xml2/xmlrpc_server.php <?php // some functions to be exposed via XML-RPC function uptime_func($method_name, $params, $app_data) { return shell_exec('uptime'); } function ls_func($method_name, $params, $app_data) { $args = ''; foreach ($params as $parm) { $args .= escapeshellarg($parm) . ' '; } return shell_exec("ls {$args}"); } // create server $xmlrpc_server = xmlrpc_server_create(); // Register PHP functions as XML-RPC methods xmlrpc_server_register_method($xmlrpc_server, "ls", "ls_func"); xmlrpc_server_register_method($xmlrpc_server, "uptime", "uptime_func"); // execute XML-RPC method based on the request which can be found inside // _GET['query']. The returned response is immediately returned to the user echo xmlrpc_server_call_method($xmlrpc_server, base64_decode($_GET['query']), NULL); // free resources xmlrpc_server_destroy($xmlrpc_server); ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlrpc_server.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlrpc_server.xml +++ presentations/slides/php5xml2/xmlrpc_server.xml <slide title="XMLRPC Server"> <example filename="xmlrpc_server.php" fontsize="1.4em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwrite.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwrite.php +++ presentations/slides/php5xml2/xmlwrite.php <?php // begin a new memory based XML document $w = xmlwriter_open_memory(); // set indenting (makes output readable) xmlwriter_set_indent($w, TRUE); xmlwriter_start_document($w); // start document xmlwriter_start_element($w, "test"); // start <test> xmlwriter_start_element($w, "example"); // start node <example> xmlwriter_write_attribute($w, "id", 1); // add attribute to example xmlwriter_start_element($w, "data"); // add node <data> xmlwriter_text($w, "Some text"); // add content to node xmlwriter_end_element($w); // close node // close all open nodes xmlwriter_end_element($w); xmlwriter_end_element($w); // end document xmlwriter_end_document($w); // output generated XML echo '<pre>'.htmlentities(xmlwriter_output_memory($w)).'</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwrite2.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwrite2.php +++ presentations/slides/php5xml2/xmlwrite2.php <?php // use xmlwriter_open_uri() for direct file writes $w = xmlwriter_open_memory(); xmlwriter_set_indent($w, TRUE); xmlwriter_start_element($w, "source"); xmlwriter_start_element($w, "php"); // add raw data via CDATA xmlwriter_start_cdata($w); xmlwriter_text($w,"<?php phpinfo(); ?>"); xmlwriter_end_cdata($w); xmlwriter_end_element($w); xmlwriter_end_element($w); echo '<pre>' . htmlentities(xmlwriter_output_memory($w)) . '</pre>';; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwrite3.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwrite3.php +++ presentations/slides/php5xml2/xmlwrite3.php <?php $w = xmlwriter_open_memory("writer.xml"); xmlwriter_set_indent($w,true); // verbose version xmlwriter_start_element_ns($w,"dc","subject","http://purl.org/dc/elements/1.1/"); xmlwriter_text($w,"Verbose"); xmlwriter_end_element($w); // simpler version xmlwriter_write_element_ns($w,"dc","subject", "http://purl.org/dc/elements/1.1/", "Simple"); echo '<pre>'.htmlentities(xmlwriter_output_memory($w)).'</pre>'; ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwriter.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwriter.xml +++ presentations/slides/php5xml2/xmlwriter.xml <slide title="XmlWriter"> <blurb fontsize="5em" align="center"> XmlWriter </blurb> <image filename="writer.gif" align="right" /> <list fontsize="3em"> <bullet>Writes XML Streams directly to disk or memory</bullet> <bullet>Based on LibXML 2</bullet> <bullet>Procedural API Only</bullet> <bullet>Newest XML Extension (PECL)</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwriter_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwriter_ex.xml +++ presentations/slides/php5xml2/xmlwriter_ex.xml <slide title="XmlWriter in Action"> <example filename="xmlwrite.php" hide="0" result="1" type="php" fontsize="2em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwriter_ex2.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwriter_ex2.xml +++ presentations/slides/php5xml2/xmlwriter_ex2.xml <slide title="XmlWriter in Action Cont."> <example filename="xmlwrite2.php" hide="0" result="1" type="php" fontsize="2em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwriter_ex3.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwriter_ex3.xml +++ presentations/slides/php5xml2/xmlwriter_ex3.xml <slide title="XmlWriter &amp; Namespaces."> <example filename="xmlwrite3.php" hide="0" result="1" type="php" fontsize="2em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xmlwriter_sum.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xmlwriter_sum.xml +++ presentations/slides/php5xml2/xmlwriter_sum.xml <slide title="XmlWriter Summary"> <list fontsize="3em" title="XmlWriter Summary"> <bullet>Fast &amp; simple way to generate valid XML.</bullet> <bullet>Automatic handling of special characters.</bullet> <bullet>|FF0000|Write only, no append.|</bullet> <bullet>|FF0000|Very new &amp; Experimental|</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xpath.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xpath.xml +++ presentations/slides/php5xml2/xpath.xml <slide title="XPath"> <image filename="xpath.jpg" align="right" /> <list title="XPath" fontsize="3.5em"> <bullet>W3C Standard</bullet> <bullet>XPath is a language for addressing parts of an XML document</bullet> <bullet>Supported by many programming languages</bullet> <bullet>Very important for XSLT</bullet> <bullet>Accesses an XML document similar to a filesystem</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xslt.php?r=1.1&p=1 Index: presentations/slides/php5xml2/xslt.php +++ presentations/slides/php5xml2/xslt.php <?php $path = dirname(__FILE__) . '/'; /* load XSLT Stylesheet as if it were a regular XML file via DOM extension */ $xslDom = new domdocument; $xslDom->load($path . 'forum.xsl'); /* load the actual XML data we will use to populate the stylesheet */ $xmlDom = new domdocument; $xmlDom->load($path . 'thedata.xml'); $xsl = new XsltProcessor; // instantiate XSLT processor $xsl->importStylesheet($xslDom); // load stylesheet echo $xsl->transformToXML($xmlDom); // perform the transformation & return HTML ?> http://cvs.php.net/co.php/presentations/slides/php5xml2/xslt.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xslt.xml +++ presentations/slides/php5xml2/xslt.xml <slide title="XSLT via XSL Extension"> <image filename="transformer.gif" align="right" /> <blurb fontsize="3em"> XSLT is a language designed to facilitate XML transformations, in XML itself. </blurb> <list> <bullet>Uses DOM extension</bullet> <bullet>Supports most EXSLT (www.exslt.org)</bullet> <bullet>Transform DOM to DOM, HTML, File or XML</bullet> </list> <break /> <blurb fontsize="2.5em"> Replacement for XSLT extension in PHP 4. </blurb> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xslt_ex.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xslt_ex.xml +++ presentations/slides/php5xml2/xslt_ex.xml <slide title="XSLT Transformation"> <example filename="xslt.php" result="1" fontsize="1.5em" /> </slide> http://cvs.php.net/co.php/presentations/slides/php5xml2/xslt_stylesheet.xml?r=1.1&p=1 Index: presentations/slides/php5xml2/xslt_stylesheet.xml +++ presentations/slides/php5xml2/xslt_stylesheet.xml <slide title="XSLT Stylesheet"> <example filename="forum.xsl" fontsize="1.5em" /> </slide>
« previous php.pres (#1136) next »