Online
 
Friday, 09 January 2009
 
 
More article:
Related Content:

PHP5 and XSLT
 
Article Index
PHP5 and XSLT
Page 2
Page 3
 

  • Lines 1 and 25 begin and end the PHP script and should at this point need little further explanation.

  • Lines 3 and 4 create and define variables to hold the names of the input XML file and the XSLT stylesheet, respectively.

  • Lines 6 and 7 create new DomDocument objects, capable of holding and manipulating well-formed XML documents (including XHTML and XSLT documents, which are also generally well-formed XML documents). These will be used to hold the XML input file and the XSLT stylesheet, respectively.

  • Line 9 calls the load() property of the $xml_obj DomDocument object to load the XML file given by the $path_xml variable defined in line 3.

  • Lines 10 and 11 display an error message and end execution if for some reason the XML input file can't be loaded or processed.

  • Line 14 calls the load() property of the $xsl_obj DomDocument object to load the XSLT file given by the $path_style variable defined in line 4.

  • Lines 15 and 16 display an error message and end execution if for some reason the XSLT input file can't be loaded or processed.

  • Line 19 creates a new XSLT processor resource at $xslt_parse, which can then be used for XSLT transformations.

  • Line 21 calls the importStyleSheet() property of the $xslt_parse resource to parse the XML document stored in $xsl_obj as an XSLT stylesheet in particular.

  • Line 23 calls the transformToXML() property of the $xslt_parse resource to apply the parsed XSLT stylesheet to the XML tree in $xml_obj; because the transformToXML() property returns a string in this case (the transformed HTML document), the echo command has been called to output this string to the Web browser.

Again, using other PHP skills you have already acquired, you should be able to incorporate these tools easily into more complex scripts.



Tags: Add more tags...,
This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment. Tags: Simple PHP, Pear, Easy PHP, PHP Tutorial, PHP MySQL, XSLT, Sap Tutorial, CSS Tutorial, XSL FO Java, SQL Tutorial.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 4000
 Notify me of follow-up comments
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage
Enter what you see:

No comment posted

Natural 112
Statistic


Last Post

 
Top! Top!