note 46063 added to function.xsl-xsltprocessor-register-php-functions

From: Date: Tue, 28 Sep 2004 13:24:37 +0000
Subject: note 46063 added to function.xsl-xsltprocessor-register-php-functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-77518@lists.php.net to get a copy of this message
I think it help your. <?php function dateLang () { return strftime("%A"); } $xsl = new DomDocument(); $xsl->load("datetime.xsl"); $inputdom = new DomDocument(); $inputdom->load("today.xml"); $proc = new XsltProcessor(); $proc->registerPhpFunctions(); // Load the documents and process using $xslt $xsl = $proc->importStylesheet($xsl); /* transform and output the xml document */ $newdom = $proc->transformToDoc($inputdom); print $newdom->saveXML(); ?> Here's the XSLT stylesheet, datetime.xsl, that will call that function: <?xml version="1.0" encoding="iso-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl"> <xsl:template match="/"> <xsl:value-of select="php:function('dateLang')" /> </xsl:template> </xsl:stylesheet> And here's an absolute minimal XML file, today.xml, to pass through the stylesheet (although articles.xml would achieve the same result): <?xml version="1.0" encoding="iso-8859-1" ?> <today></today> ---- Manual Page -- http://www.php.net/manual/en/function.xsl-xsltprocessor-register-php-functions.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46063 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46063&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46063&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77518) next »