server-php-xml-class-xslt-class-xslt.htm / htm
<html> <head> <title>Xslt (class_xslt.php)</title> <link rel="stylesheet" href="main.css" type="text/css"> </head> <body> <div align="center"> <table border="0" width="80%" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#aaaaee" class="text" align="center"><a href="http://phpxmlclasses.sourceforge.net/">PHP XML Classes</a></td> </tr> </table> <table border="0" width="80%" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#aaaaee" class="textblbl" align="center">Xslt (class_xslt.php)</td> </tr> </table> <br/> <table border="0" width="80%"> <tr> <td bgcolor="#eeeeff" class="text">Description: This class is an abstraction class for an XSLT processor, it let's you setup the XML to be processed and the XSLT stylesheet to use from a file or a PHP string. This implementation uses the Sablotron XSLT processor and was updated to work with the new PHP 4.1.x xslt extension. </td> </tr> </table> <br/> <table border="0" bgcolor="ddddff" width="80%"> <tr> <td valign="top" class="text" width="50%"><b>NEWS:</b> <ul> <li>5-15-2002 Updated to work under PHP 4.2.x </ul> </td> <td valign="top" width="50%" class="text"> This class code as well as the documentation are hosted at <a href="http://www.sourceforge.net">SourceForge</a> please visit our <a href="http://phpxmlclasses.sourceforge.net">SourceForge page</a> for releases, documentation, bug-tracking, support forums and mailing lists. </td> </tr> </table> <br/> <table border="0" width="80%" cellpadding="0" cellspacing="0"> <tr> <td class="textbl" bgcolor="aaaaee" width="50%">Resources</td> <td class="textbl" bgcolor="aaaaee" width="50%">Requirements</td> </tr> </table> <table border="1" width="80%" cellpadding="0" cellspacing="0"> <tr> <td valign="top" bgcolor="eeeeff" class="text" width="50%"> <ul> <li><a class="textbl" href="http://www.sourceforge.net/projects/phpxmlclasses">Downloads</a> <li><a class="textbl" href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpxmlclasses/xslt/">Browse CVS</a> <li><a class="textbl" href="http://sourceforge.net/tracker/?atid=470965&group_id=53613&func=browse">Report Bugs</a> </ul> </td> <td valign="top" bgcolor="eeeeff" class="text" width="50%"> <ul> <li>PHP 4.0.5+ <li>XSLT extension </ul> </td> </tr> </table> <br/> <table border="0" width="80%" cellpadding="0" cellspacing="0"> <tr> <td class="textbl" bgcolor="aaaaee" width="50%">Features</td> <td class="textbl" bgcolor="aaaaee" width="50%">To-dos</td> </tr> </table> <table border="1" width="80%" cellpadding="0" cellspacing="0"> <tr> <td valign="top" bgcolor="eeeeff" class="text" width="50%"> <ul> <li>Can receive the XML source as a string or a file (http://) works too. <li>Can receive the XSLT stylesheet as a string or a file (http://) works too. </ul> </td> <td valign="top" bgcolor="ddddff" class="text" width="50%"> <ul> <li>Option to cache transformations for incresed speed. </ul> </td> </tr> </table> <br/> <table border="0" bgcolor="ddddff" width="80%"> <tr> <!-- <td valign="top" class="text" width="50%"><b>To-do/future releases:</b> <ul> <li>Class <li>Class <li>Class </ul> </td> --> <td valign="top" width="100%" class="text"> Contact: </td> </tr> </table> <br/> <table border="0" bgcolor="ddddff" width="80%"> <tr> <!-- <td valign="top" class="text" width="50%"><b>To-do/future releases:</b> <ul> <li>Class <li>Class <li>Class </ul> </td> --> <td valign="top" width="100%" class="text"> Detailed description and usage:<br/> Using the class: <pre> include_once("class_xslt.php"); xslt->setXml("applications.xml"); // or setXmlString( xslt->setXsl("tr1.xsl"); // or steXslString( if(xslt->transform()) { xslt->getOutput(); echo xslt->getError()); }</pre> <br/> <h3>Documentation</h3> </div> <h2>Classes</h2> <ul> <li><a href="#class19">class_xslt</a></li> </ul> <a name="class19"></a> <h3>class_xslt</h3> Extends: None
Description: Class to handle XSLT transformations, the XML documents and the XSLT stylesheet can be passed as files or PHP strings.
<br> <!-- METHOD SUMMARY --> <A NAME="pDomNode_method_summary"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Method Summary</B></FONT></TD> </TR> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="#class19method1">Xslt</A></B>()</CODE> <BR> Constructor</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="#class19method2">destroy</A></B>()</CODE> <BR> Destructor</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> string</CODE></FONT></TD> <TD><CODE><B><A HREF="#class19method3">getOutput</A></B>()</CODE> <BR> Returns the result of the XSLT transformation</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="#class19method4">setXmlString</A></B>(string uri)</CODE> <BR> Sets the XML to be transformed from a URI</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="#class19method6">setXslString</A></B>(string uri)</CODE> <BR> Sets the XSLT stylesheet to be used from a URI</TD> </TR> <!-- A ROW --> <!-- A ROW --> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="#class19method8">transform</A></B>(string uri)</CODE> <BR> Returns the error message if a transformation fails</TD> </TR> <!-- A ROW --> </TABLE> <P> <!-- METHOD SUMMARY --> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Method Detail</B></FONT></TD> </TR> </TABLE> <!-- method --> <A NAME="class19method1"><!-- --></A> <H3>Xslt</H3> <PRE> void <B>Xslt</B>(string uri)</PRE> <DL> <DD>Object destructor should be called to free resources allocated for the Sablotron processor.<DD> <DL> <DT><B>Parameters:</B><DD> <DT><B>Returns:</B><DD>Nothing<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class19method3"><!-- --></A> <H3>getOutput</H3> <PRE> string <B>getOutput</B>(string xml)</PRE> <DL> <DD>This method sets the XML that is going to be transformed from a PHP string.<DD> <DL> <DT><B>Parameters:</B><DD> <br><DT><B>Returns:</B><DD>Nothing<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class19method5"><!-- --></A> <H3>setXml</H3> <PRE> void <B>setXml</B>(string uri)</PRE> <DL> <DD>This method sets the XML to be transformed from a URI, it can be a file in the local file system or a http:// form URI pointing to an XML file.<DD> <DL> <DT><B>Parameters:</B><DD> <br><DT><B>Returns:</B><DD>Nothing<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class19method6"><!-- --></A> <H3>setXslString</H3> <PRE> void <B>setXslString</B>(string xsl)</PRE> <DL> <DD>This method sets the XSLT stylesheet to be used from a PHP string.<DD> <DL> <DT><B>Parameters:</B><DD> <br><DT><B>Returns:</B><DD>Nothing<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class19method7"><!-- --></A> <H3>setXsl</H3> <PRE> void <B>setXsl</B>(string uri)</PRE> <DL> <DD>This method sets the XSLT stylesheet to be used from a URI, it can be a file in the local file system or a http:// form URI pointing to the location of an XSLT file.<DD> <DL> <DT><B>Parameters:</B><DD> <br><DT><B>Returns:</B><DD>Nothing<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class19method8"><!-- --></A> <H3>transform</H3> <PRE> boolean <B>transform</B>(string uri)</PRE> <DL> <DD>Once an XML and an XSLT are set this method performs the XSLT transformation, the result can be obtained using the getOutput method.<DD> <DL> <DT><B>Parameters:</B><DD> <DT><B>Returns:</B><DD>true/false indicating if the transformation was succesful<DT><B>Throws:</B><DD><CODE>None</CODE> </DL> </DD> </DL> <HR> <!-- a method --> <!-- method --> <A NAME="class19method9"><!-- --></A> <H3>getError</H3> <PRE> string <B>getError</B>(string </body> </html>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.