Detailed description and usage:
Using the class:
include_once("class_xslt.php");
$xslt=new Xslt();
$xslt->setXml("applications.xml"); // or setXmlString($xml) if the xml is in a php string
$xslt->setXsl("tr1.xsl"); // or steXslString($xsl) if the xsl is in a php string
if($xslt->transform()) {
$ret=$xslt->getOutput();
echo $ret;
} else {
print("Error:".$xslt->getError());
}
Documentation
Classes
class_xslt
Extends: None
Description: Class to handle XSLT transformations, the XML documents and
the XSLT stylesheet can be passed as files or PHP strings.
Method Summary |
void |
Xslt()
Constructor |
void |
destroy()
Destructor |
string |
getOutput()
Returns the result of the XSLT transformation |
void |
setXmlString(string $xml)
Sets the XML to be transformed from a string |
void |
setXml(string $uri)
Sets the XML to be transformed from a URI |
void |
setXslString(string $xsl)
Sets the XSLT stylesheet to be used from a string |
void |
setXsl(string $uri)
Sets the XSLT stylesheet to be used from a URI |
boolean |
transform(string $uri)
Performs an XSLT transformation |
string |
getError(string $uri)
Returns the error message if a transformation fails |
Xslt
void Xslt(string $uri)
- Constructor (no parameters)
-
- Parameters:
-
- Returns:
- Nothing
- Throws:
None
destroy
void destroy(string $uri)
- Object destructor should be called to free resources allocated for the Sablotron processor.
-
- Parameters:
-
- Returns:
- Nothing
- Throws:
None
getOutput
string getOutput(string $uri)
- This returns the result of the last XSLT transformation
-
- Parameters:
-
- Returns:
- Transformation result's
- Throws:
None
setXmlString
void setXmlString(string $xml)
- This method sets the XML that is going to be transformed from a PHP string.
-
- Parameters:
-
$xml -
- Returns:
- Nothing
- Throws:
None
setXml
void setXml(string $uri)
- 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.
-
- Parameters:
-
$uri - It can be a file, example "foo.xml" or a remote file, example: "http://foo.com/foo.xml"
- Returns:
- Nothing
- Throws:
None
setXslString
void setXslString(string $xsl)
- This method sets the XSLT stylesheet to be used from a PHP string.
-
- Parameters:
-
$xsl - The XSLT stylesheet as a PHP string
- Returns:
- Nothing
- Throws:
None
setXsl
void setXsl(string $uri)
- 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.
-
- Parameters:
-
$uri - Use "foo.xslt" to point to a XSLT file in the local file system or "http://foo.com/foo.xsl" for a remote XSLT stylesheet.
- Returns:
- Nothing
- Throws:
None
transform
boolean transform(string $uri)
- Once an XML and an XSLT are set this method performs the XSLT transformation, the result can be obtained using the getOutput method.
-
- Parameters:
-
- Returns:
- true/false indicating if the transformation was succesful
- Throws:
None
getError
string getError(string $uri)
- This method returns the error message when the transform() method returns false
-
- Parameters:
-
- Returns:
- Error description
- Throws:
None
|