If you're new to this like I am you will find this xslt stylesheet quite revealing. It was a lot of fun to create:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "*">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<xsl:variable name="header">
<tr bgcolor="#cccccc">
<th style="text-align:left;width:10%">ID</th>
<th style="text-align:left;width:60%">Course Name</th>
<th style="text-align:left;width:30%">Instructor Name</th>
</tr>
</xsl:variable>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<table style="width:100%;border-collapse:collapse;border:none;font:normal 0.7em 'Trebuchet MS',Arial,sans-serif">
<xsl:copy-of select="$header" />
<xsl:for-each select="document/row">
<tr>
<td><xsl:value-of select="id"/></td>
<td>
<a>
<xsl:attribute name="href" >
index.php?id=<xsl:value-of select="courseid"/>
</xsl:attribute>
<xsl:attribute name="target" >
_top
</xsl:attribute>
<xsl:value-of select="coursename"/>
</a>
</td>
<td>
<a>
<xsl:attribute name="href" >
/instructors/index.php?id=<xsl:value-of select="instructorid"/>
</xsl:attribute>
<xsl:attribute name="target" >
_top
</xsl:attribute>
<xsl:value-of select="instructorname"/>
</a>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The data being parsed is seven columns by N records, with links being affixed to text in one column from data stored in another. Only three of the columns are actually displayed. This particular example is live in an iframe. Sadly it does not get parsed in PHP, but by the browser.
If you get an answer to your question it's hoped I may get an answer to mine. I've included this example to illustrate the relationship between the data set and the style sheet template. Like many of my projects, this is a scratch on the surface but it works, for now, until a php solution can be found.
Here is a segment of the xml. Note the stylesheet element...
Code:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="courses.xsl" ?>
<document>
<row>
<id>1</id>
<courseid>stress_perception</courseid>
<coursename>All Stressed Up and No Place to Go</coursename>
<instructorid>deb_milne</instructorid>
<instructorname>Deb Milne</instructorname>
<objective>1</objective>
<flag>1</flag>
</row>
<row>
<id>2</id>
<courseid>asist</courseid>
<coursename>Applied Suicide Intervention Skills Training</coursename>
<instructorid>csp_asist</instructorid>
<instructorname>Center for Suicide Prevention</instructorname>
<objective>1</objective>
<flag>1</flag>
</row>
<row>
<id>3</id>
<courseid>first_aid_training</courseid>
<coursename>St. John Ambulance First Aid</coursename>
<instructorid>st_john_ambulance</instructorid>
<instructorname>St. John Ambulance Training</instructorname>
<objective>1</objective>
<flag>1</flag>
</row>
<row>
<id>4</id>
<courseid>cpr-aed</courseid>
<coursename>St. John Ambulance CPR-AED</coursename>
<instructorid>st_john_ambulance</instructorid>
<instructorname>St. John Ambulance Training</instructorname>
<objective>1</objective>
<flag>1</flag>
</row>
<row>
<id>5</id>
<courseid>food_safety</courseid>
<coursename>Food Safety</coursename>
<instructorid>thor_hameister</instructorid>
<instructorname>Thor Hameister</instructorname>
<objective>1</objective>
<flag>1</flag>
</row>
</document>
Here is the XHTML to load the styled xml in an iframe:
Code:
<table id="coursetable" summary="" class="layout pagecore">
<tr><td class="leftbar"> </td>
<td class="contentbox">
<div class="shell" style="margin-bottom:1em">
<h2><a href="index.xml" title="full Course and Instructor table">Table of Courses and Instructors</a></h2>
<iframe src="courses.xml" name="cwtable" width="100%" style="border:none">
If you can see this, your browser doesn’t understand IFRAME. View the
<a href="index.xml" target="_blank"> full Course and Instructor table</a> in a new window.
</iframe>
</div>
</td>
</tr>
</table>