Code: Select all
<?php
function transformxml ($sourcexml, $sourcexsl)
{
$sourcexml = 'file://' . $sourcexml;
$sourcexsl = 'file://' . $sourcexsl;
$xslt = xslt_create();
//process the document
if(!$result = @xslt_process($xslt, $sourcexml, $sourcexsl))
{
print ("Error: " . xslt_error($xslt) . " Error Num: " . xslt_errno($xslt));
die();
}
xslt_free($xslt);
return $result;
}
//get source file locations
$sourcexsl = $_POST["delnotexsl"];
$sourcexml = $_POST["delnotexml"];
//delnotexml is the post name of the file and delnotexsl is a hidden
//field with the location of my xsl doc
print (transformxml($sourcexml, $sourcexsl));
?>Admin Edit: added
Code: Select all
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<body>
<h3>Please select a dvd to add to the database</h3>
<table>
<tr> <th>Title</th><th>Duration</th><th>Release Date</th><th>Price</th><th>Quan.</th></tr>
<xsl:for-each select="//DVD">
<tr>
<form action="insertfromxml.php" method="post">
<xsl:apply-templates select="DVD_TITLE"/>
<xsl:apply-templates select="DVD_DURATION"/>
<xsl:apply-templates select="DVD_RELEASE_DATE"/>
<xsl:apply-templates select="DVD_PRICE"/>
<xsl:apply-templates select="QUANTITY"/>
<td> <input type="submit" value="Insert This DVD" /></td>
</form>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="DVD_TITLE">
<td>
<input type="text" size="30" name="txtTITLE">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="DVD_DURATION">
<td>
<input type="text" size="5" name="txtDURATION">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="DVD_RELEASE_DATE">
<td>
<input type="text" size="15" name="txtRELEASE">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="DVD_PRICE">
<td>
<input type="text" size="6" name="txtPRICE">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
<xsl:template match="QUANTITY">
<td>
<input type="text" size="4" name="txtQUANTITY">
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:template>
</xsl:stylesheet>Thanks for any help
James Baker