Re: About PHP CMS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 8:24 PM -0400 7/7/07, Nathan Nobbe wrote:
kelvin,

here is the example:
catalog.php
<?php
$doc = new DOMDocument();
$xsl = new XSLTProcessor();
$doc->load('catalog.xsl');
$xsl->importStyleSheet($doc);
$doc->load('catalog.xml');
echo $xsl->transformToXML($doc);
?>

catalog.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>

catalog.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>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title" /></td>
<td><xsl:value-of select="artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


in this example the xml data is imported from a file rather than built in
memory.  also, i would like to mention that most browsers, ie, firefox and
opera namely can render the xhtml themselves given the xml and xsl files
which is something you may want to consider.

-nathan


Nice example.

Now, get it to validate and remove the styling attributes.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux