Calling the Saxon XSLT Processor is a very esay task to do!
You just need to do some simple task
1. Install the JavaBridge for PHP
2. Download the freeware (B) Saxon distribution from http://saxon.sourceforg
e.net/
3. Put the jar files in a directory whre you have access
4. Use this sample of code
// Directory where the jar files are located
define("SAXON_DIR",
$_SERVER['DOCUMENT_ROOT']."/saxonb8.9.0/");
// include the jars
java_require(SAXON_DIR."saxon8.jar;".SAXON_DIR.&qu
ot;saxon8-dom.jar");
$sXslFile =
$_SERVER['DOCUMENT_ROOT']."/myfirst.xsl"; // The
xsl file
$sXmlFile =
$_SERVER['DOCUMENT_ROOT']."/myfirst.xml"; // The
xml file
try
{
$oXslSource = new
java("javax.xml.transform.stream.StreamSource",
"file://".$sXslFile);
$oXmlSource = new
java("javax.xml.transform.stream.StreamSource",
"file://".$sXmlFile);
$oFeatureKeys = new
JavaClass("net.sf.saxon.FeatureKeys");
// Create the Factory
$oTransformerFactory = new
java("net.sf.saxon.TransformerFactoryImpl");
//Disable source document validation
$oTransformerFactory->setAttribute($oFeatureKeys->SCHE
MA_VALIDATION, 4);
// Create a new Transformer
$oTransFormer =
$oTransformerFactory->newTransformer($oXslSource);
// Create a StreamResult to store the output
$oResultStringWriter = new
java("java.io.StringWriter");
$oResultStream = new
java("javax.xml.transform.stream.StreamResult",
$oResultStringWriter);
// Transform
$oTransFormer->transform($oXmlSource, $oResultStream);
// Echo the output from the transformation
echo java_cast($oResultStringWriter->toString(),
"string");
}
catch(JavaException $e){
echo java_cast($e->getCause()->toString(),
"string");
exit;
}
5. Enjoy
This is working quite well.
----
Server IP: 81.223.48.75
Probable Submitter: 88.117.36.190
----
Manual Page -- http://www.p
hp.net/manual/en/ref.xsl.php
Edit -- https://master
.php.net/note/edit/78436
Del: integrated -- h
ttps://master.php.net/note/delete/78436/integrated
Del: useless -- http
s://master.php.net/note/delete/78436/useless
Del: bad code -- htt
ps://master.php.net/note/delete/78436/bad+code
Del: spam -- https:/
/master.php.net/note/delete/78436/spam
Del: non-english --
https://master.php.net/note/delete/78436/non-english
Del: in docs -- http
s://master.php.net/note/delete/78436/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78436
Reject -- https://mast
er.php.net/note/reject/78436
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|