You can find mor Examples at PHP Sources php-5.*/ext/xsl/tests
<?php
$xform = <<<EOT
<?xml version = '1.0' encoding = 'utf-8' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl"
xsl:extension-element-prefixes="php"
>
<xsl:output method="xml" indent="yes" encoding="utf-8" />
<xsl:namespace-alias stylesheet-prefix="php" result-prefix="xsl" />
<xsl:template match="root">
<html>
<head>
<title>Dateformat</title>
</head>
<body>
<xsl:for-each select="datenode">
<li>
<xsl:value-of select="php:functionString('convertDate', . )" />
</li>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
EOT;
function convertDate( $i )
{
setlocale( LC_TIME, 'de_DE' );
return utf8_encode( strftime( '%B %d %A %Y %H:%M:%S CET', $i ) );
}
$xsl = new XSLTProcessor;
$xsl->registerPHPFunctions();
$xsl->setParameter( 'DOCTYPE', 'PUBLIC', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' );
$xsl->setParameter( 'html', 'xmlns', 'http://www.w3.org/1999/xhtml' );
$xdom = new DomDocument( '1.0', 'utf-8' );
$xdom->loadXML( $xform );
$xsl->importStyleSheet( $xdom );
unset( $xdom );
$dom = new DomDocument( '1.0', 'utf-8' );
$r = $dom->appendChild( $dom->createElement( 'root' ) );
foreach ( range( 1, 12 ) AS $i ) {
$r->appendChild( $dom->createElement( 'datenode', mktime( date('G'), date('i'), date('s'), $i, date('d'), date('Y') ) ) );
}
header( "Content-Type: text/html; charset=utf-8;" );
header( "Content-Encoding: utf-8" );
echo $xsl->transformToXML( $dom );
?>