Hello folks,
I am very new to xml-related language, I have a dynamically generated xml file, I need to transform it to html, I have a sample xlst, but it is just not working, can anyone tell me how to do it? the xml file is as following:
<Order>
<d>
<DocID>129</DocID>
<nextreviewdate>2009-03-01T00:00:00</nextreviewdate>
<i>
<Code>KS</Code>
<title>Acceptance to transmit electronically VISA Transactions Report and Billing Files from BCE</title>
<ref>2002-6</ref>
<doctype>Risk Acceptance Letter</doctype>
<u>
<Consultant>Stephen</Consultant>
</u>
</i>
</d>
<d>
<DocID>135</DocID>
<nextreviewdate>2010-04-12T00:00:00</nextreviewdate>
<i>
<Code>KS</Code>
<title>Host Based PIN (HBP) Project</title>
<ref>2001-10</ref>
<doctype>Risk Acceptance Letter</doctype>
<u>
<Consultant>Stephen</Consultant>
</u>
</i>
</d>
</Order>
Here is the "wrong" xlst:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="Order">
<html>
<head>
<style type="text/css">
body {margin-left: 20px; font-family: segoe ui, tahoma, sans-serif;}
h1 {color: #f00;}
h2 {size: 70%; color: #00f;}
td {padding-right: 10px;}
</style>
</head>
<body>
<h1>Document List</h1>
<xsl:apply-templates select="oh"/>
</body>
</html>
</xsl:template>
<xsl:template match="oh">
<DIV style="margin-bottom:20px;">
<table>
<tr>
<th>Code</th>
<th>DocID</th>
<th>Ref</th>
<th>Title</th>
<th>doctype</th>
<th>NextReviewDate</th>
</tr>
<xsl:apply-templates select="p"/>
</table>
</DIV>
<hr />
<p style="font-size: 70%;"><a href=" 2009</p>
</xsl:template>
<xsl:template match="p">
<div style="color:#f00; font-size: 90%;">
<tr>
<td><xsl:value-of select="Code"/></td>
<td><xsl:value-of select="DocID"/></td>
<td><xsl:value-of select="Ref"/></td>
<td><xsl:value-of select="Title"/></td>
<td><xsl:value-of select="doctype"/></td>
<td><xsl:value-of select="NextReviewDate"/></td>
</tr>
</div>
</xsl:template>
<xsl:template match="NoRecords">
<html>
<head>
<style type="text/css">
body {margin-left: 20px; font-family: tahoma, sans-serif;}
</style>
</head>
<body>
<h1>Daily Order Totals</h1>
<div>
No sales records were found for the specified date.
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thank you very much.
I am very new to xml-related language, I have a dynamically generated xml file, I need to transform it to html, I have a sample xlst, but it is just not working, can anyone tell me how to do it? the xml file is as following:
<Order>
<d>
<DocID>129</DocID>
<nextreviewdate>2009-03-01T00:00:00</nextreviewdate>
<i>
<Code>KS</Code>
<title>Acceptance to transmit electronically VISA Transactions Report and Billing Files from BCE</title>
<ref>2002-6</ref>
<doctype>Risk Acceptance Letter</doctype>
<u>
<Consultant>Stephen</Consultant>
</u>
</i>
</d>
<d>
<DocID>135</DocID>
<nextreviewdate>2010-04-12T00:00:00</nextreviewdate>
<i>
<Code>KS</Code>
<title>Host Based PIN (HBP) Project</title>
<ref>2001-10</ref>
<doctype>Risk Acceptance Letter</doctype>
<u>
<Consultant>Stephen</Consultant>
</u>
</i>
</d>
</Order>
Here is the "wrong" xlst:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="Order">
<html>
<head>
<style type="text/css">
body {margin-left: 20px; font-family: segoe ui, tahoma, sans-serif;}
h1 {color: #f00;}
h2 {size: 70%; color: #00f;}
td {padding-right: 10px;}
</style>
</head>
<body>
<h1>Document List</h1>
<xsl:apply-templates select="oh"/>
</body>
</html>
</xsl:template>
<xsl:template match="oh">
<DIV style="margin-bottom:20px;">
<table>
<tr>
<th>Code</th>
<th>DocID</th>
<th>Ref</th>
<th>Title</th>
<th>doctype</th>
<th>NextReviewDate</th>
</tr>
<xsl:apply-templates select="p"/>
</table>
</DIV>
<hr />
<p style="font-size: 70%;"><a href=" 2009</p>
</xsl:template>
<xsl:template match="p">
<div style="color:#f00; font-size: 90%;">
<tr>
<td><xsl:value-of select="Code"/></td>
<td><xsl:value-of select="DocID"/></td>
<td><xsl:value-of select="Ref"/></td>
<td><xsl:value-of select="Title"/></td>
<td><xsl:value-of select="doctype"/></td>
<td><xsl:value-of select="NextReviewDate"/></td>
</tr>
</div>
</xsl:template>
<xsl:template match="NoRecords">
<html>
<head>
<style type="text/css">
body {margin-left: 20px; font-family: tahoma, sans-serif;}
</style>
</head>
<body>
<h1>Daily Order Totals</h1>
<div>
No sales records were found for the specified date.
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thank you very much.