Re: PHP5 XSLT how to.
| From: | William Bailey | Date: | Fri, 05 Dec 2003 17:39:48 +0000 |
| Subject: | Re: PHP5 XSLT how to. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172007@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ok Just incase anybody else would like to know how to do it i found that
the following works:
PHP Code ----
$dom = new DomDocument();
$aboutNode = $dom->appendChild($dom->createElement('about'));
$aboutNode->setAttribute('name', 'My Application');
$versionNode = $aboutNode->appendChild($dom->createElement('version'));
$versionNode->setAttribute('major', 0);
$versionNode->setAttribute('minor', 1);
$versionNode->setAttribute('revision', 5);
$versionNode->appendChild($dom->createTextNode('Its a test'));
$xsl = new domDocument();
$xsl->load('loading.xsl');
$proc = new xsltprocessor;
$proc->importStylesheet($xsl);
print($proc->transformToXml($dom));
loading.xsl ---
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>About</title>
</head>
<body>
~ <h1 style="text-align:center; margin: 0; padding: 0;"><xsl:value-of select="/about/@name"/>
~ v<xsl:value-of select="/about/version/@major"/>.<xsl:value-ofselect="/about/version/@minor"/>.<xsl:value-of select="/about/version/@revision"/> (<xsl:value-of select="/about/version"/>)</h1> </body> </html> </xsl:template> </xsl:stylesheet> - --- Regards, William Bailey. Pro-Net Internet Services Ltd. http://www.pro-net.co.uk/ | William Bailey wrote: | | Hello again. |
| I am currently testing the php5 beta and really like the new DOM| objects but i am haveing trouble finding out how i can apply a XSLT | template to a DOM document. Does anybody know how i can do this? | | I have tried looking at the DOM documentation in the online php manual | but am finding it to be all out of date in respect to the php5 | implementation so if anybody could also point me to the correct | information i would be very happy. | | -- | Regards,
| William Bailey. | Pro-Net Internet Services Ltd. | http://www.pro-net.co.uk/|> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE/0MLkzSfrYDJMXmERAuTIAKCXEXZz/du+27Gvs8H5AYlOnA8zPgCfYjdb W4hfTj5ah+a57Cn9kp01rLQ= =MUEY -----END PGP SIGNATURE-----