Presentation is loading. Please wait.

Presentation is loading. Please wait.

Loading methods in PHP DOMDocument class DOMDocument extends DOMNode {... mixed load ( string $filename.

Similar presentations


Presentation on theme: "Loading methods in PHP DOMDocument class DOMDocument extends DOMNode {... mixed load ( string $filename."— Presentation transcript:

1 Loading methods in PHP DOMDocument class http://php.net/manual/en/class.domdocument.php DOMDocument extends DOMNode {... mixed load ( string $filename [, int $options = 0 ] ) mixed loadXML ( string $source [, int $options = 0 ] ) bool loadHTML ( string $source ) bool loadHTMLFile ( string $filename )... } We have seen that load() loads XML from a file loadXML() loads XML from a string loadHTML() loads HTML from a string –Unlike loading XML, HTML does not have to be well-formed to load load HTMLFile() loads HTML from a string –Unlike loading XML, HTML does not have to be well-formed to load

2 XSLTProcessor class in PHP http://php.net/manual/en/class.xsltprocessor.php XSLTProcessor { string getParameter ( string $namespaceURI, string $localName ) bool hasExsltSupport ( void ) void importStylesheet ( object $stylesheet ) void registerPHPFunctions ([ mixed $restrict ] ) bool removeParameter ( string $namespaceURI, string $localName ) bool setParameter ( string $namespace, string $name, string $value ) bool setProfiling ( string $filename ) string transformToXML ( DOMDocument $doc ) DOMDocument transformToDoc ( DOMNode $doc ) int transformToURI ( DOMDocument $doc, string $uri ) } We have already used the blue methods above

3 transform methods in PHP XSLTProcessor class XSLTProcessor {... string transformToXML ( DOMDocument $doc ) DOMDocument transformToDoc ( DOMNode $doc ) int transformToUri ( DOMDocument $doc, string $uri ) } transformToXML() transforms the source DOMDocument to a string transformToDoc() transforms the source DOMDocument to a DOMDocument transformToUri() transforms the source DOMDocument to the URI specified in the string –For example, $processor->transformToUri($xmldoc,'output.html'); places the output from the transformation in a file called output.html

4 Global parameters for XSL stylesheets XSLT allows parameters whose scope is the entire stylesheet –Default values can be set for these parameters –External values can be passed to these parameters –If external values are passed, these override the default values The values of these parameters can then control the form of processing performed by the stylesheet

5 Global parameters in XSLT, Example Stylesheet below has a global parameter, called infoWanted, to which is gives a default value that can be over-ridden by an externally-set value Depending on value of parameter, stylesheet outputs either the names or the ages of the people in the XML document which is being processed

6 Global parameters in XSLT, Example Suppose stylesheet on previous slide is in demo304.xsl demo304.php applied it to the XML document in demo304.xml Different output is given, depending on value of query string given to demo304.php

7 parameter methods in PHP XSLTProcessor class XSLTProcessor {... bool setParameter ( string $namespace, string $name, string $value ) string getParameter ( string $namespaceURI, string $localName ) bool removeParameter ( string $namespaceURI, string $localName ) } setParameter() sets the value of parameter to be used in subsequent transformations; if the parameter doesn't exist in stylesheet, it will be ignored getParameter() gets a parameter if previously set by setParameter() removeParameter() removes a parameter, if set; this will make the processor use default value for the parameter as specified in the stylesheet

8 Profiling An XSLT profiling tool determines –which templates were called –how many times –how much time was spent executing them This information may help in re-writing the stylesheet to improve its speed of execution

9 profiling method in PHP XSLTProcessor class XSLTProcessor {... bool setProfiling ( string $filename )... } setProfiling() specifies the file to which the profiling information should be written when a stylesheet is executed Example $proc->setProfiling('profiling.txt'); specifies that profiling results will be written to the file called profiling.txt


Download ppt "Loading methods in PHP DOMDocument class DOMDocument extends DOMNode {... mixed load ( string $filename."

Similar presentations


Ads by Google