[thelist] XML to HTML

Jeana Clark jmclark at multiservice.com
Fri May 11 15:07:04 CDT 2001


I'm pretty much clueless as to how the converstion/transformation? between
xml to html (or any other "language") works.  I also know the support is
buggy to non-existant in the browsers... but I know it's being done, and I
want in on the action. eheh.  I'm wanting to know how to have the xml/xslt
results dumped into an html page.  I've come up with something (based off
follwing and reading several tutorials..)  but it farts in netscape, and
when you vew source, the data doesn't show up.  Am I needing a server side
parser(?).  I'm vague on the terminology.. so I'm hoping osmeone understands
me.  Also... I'm unable to upload anything to a server right now, so I'm
just going to paste the code :\  bear with me.  And thanks in advance for
any and all help in clearing my muddled mind.


THE XML:

<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="hotgames.xsl"?>

<hotgames>

	<software softwareid="73036">
		<name>Tribes 2 </name>
		<format>W98</format>
		<price>$47.99</price>
		<buy>?</buy>
	</software>

	<software softwareid="78085">
		<name>PC Anywhere 10.0 Host &amp; Remote</name>
		<format>W9X</format>
		<price>$178.99</price>
		<buy>?</buy>
	</software>

</hotgames>




THE STYLESHEET:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">

	<html lang="en">

	<head>
	</head>

	<body>
	<table border="0" width="550">
	<tr>
		<td>Software</td>
		<td>Format</td>
		<td>Price</td>
		<td>Buy</td>
	</tr>
	<xsl:for-each select="hotgames/software">

	<tr>
		<td width="346" bgcolor="#505050" height="30">
		<xsl:value-of select="name" />
		</td>

		 <td width="70" bgcolor="#505050" height="30">
		<xsl:value-of select="format" />
		</td>

		<td align="right" width="70" bgcolor="#505050" height="30">
		<xsl:value-of select="price" />
		</td>

		<td bgcolor="#505050" height="30" width="70">
		<xsl:value-of select="buy" />
		</td>
	</tr>

	</xsl:for-each>
	</table>

	</body>
	</html>
</xsl:template>
</xsl:stylesheet>



and.. THE HTML:

<html>
	<head>
	<title>Metropolis Gameport </title>

	<style>
		body	{
			background-color:#000000;
			}
		a, p, span, td  {
			font-family:verdana, arial, helvetica;
			font-size:10pt;
			color:#fefefe;
			}
		a:link {
			color:#99ccff;
			}
		a:visited {
			color:#99ccff:
			}
		h3 {
			color:#ffffff;
			font-size:18;
			font-family:arial, verdana, helvetica;
			}
		p {
			color:#fefefe;
			}

	</style>
	</head>


  <XML id="source" src="hotgames.xml"></XML>
  <XML id="style" src="hotgames.xsl"></XML>


  <SCRIPT FOR="window" EVENT="onload">
    xslTarget.innerHTML = source.transformNode(style.XMLDocument);
  </SCRIPT>

  <BODY>
    <DIV id="xslTarget"></DIV>
  </BODY>
</HTML>





More information about the thelist mailing list