I am trying to learn XML and interacting w/ C# and ASP.NET forms. I am not getting the output I expect, and wanted to pose that question of "why" to the group here.
My XSLT:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="html"/>
<xsl:template match="/">
<html>
<head>
<style type="text/css">
.redText {font-family:arial;co lor:#ff0000;}
.borders {border-left:1px solid #0000ff;
border-right:1px solid #00ff00;
border-top:1px solid #00ff00;
border-bottom:1px solid #0000ff;}
</style>
</head>
<body bgcolor="#00000 0">
<table class="borders" border="0" width="800" cellpadding="4"
cellspacing="0" bgcolor="#efefe f">
<xsl:apply-templates select="menuBar "/>
<tr height="100%">
<td>News Goes Here<br/>
<xsl:apply-templates select="News"/>
</td>
<td class="redText" ><xsl:apply-templates select="MainSec tion"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="News">
<table class="borders" border="0" width="640" cellpadding="4"
cellspacing="0" bgcolor="#ff88c c">
<tr><td></td></tr>
</table>
</xsl:template>
<xsl:template match="MainSect ion">
<span>Hello World!</span>
<p/>
</xsl:template>
<xsl:template match="menuBar" >
<tr>
<td>
<table class="borders" border="0" width="640" cellpadding="4"
cellspacing="0" bgcolor="#ff88c c">
<tr>
<td>register</td>
<td>menu item 1</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
My C# PageLoad Method:
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
datasets.UserIn foDS ds = new datasets.UserIn foDS();
XmlDataDocument dd = new XmlDataDocument (ds);
string xslPath = Server.MapPath( "CommonTemplate .xslt");
StringWriter sw = new StringWriter();
XslTransform xsl = new XslTransform();
xsl.Load(xslPat h);
//Instantiate the XPathDocument Class
//XPathDocument doc = new XPathDocument(x mlPath);
//Instantiate the XslTransform Class
xsl.Transform(d d,null,sw,null) ;
Response.Write( sw.ToString());
}
But I'm getting the following as output:
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-16">
<style type="text/css">
.redText {font-family:arial;co lor:#ff0000;}
.borders {border-left:1px solid #0000ff;
border-right:1px solid #00ff00;
border-top:1px solid #00ff00;
border-bottom:1px solid #0000ff;}
</style>
</head>
<body bgcolor="#00000 0">
<table class="borders" border="0" width="800" cellpadding="4" cellspacing="0" bgcolor="#efefe f">
<tr height="100%">
<td>News Goes Here<br></td>
<td class="redText" >
</td>
</tr>
</table>
</body>
</html>
I am expecting to at least see menubar words, the table under the News area, and the words Hello World in the MainSection. None of those show up. Any ideas? The dataset is just a blank dataset.
Thanks!
My XSLT:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="html"/>
<xsl:template match="/">
<html>
<head>
<style type="text/css">
.redText {font-family:arial;co lor:#ff0000;}
.borders {border-left:1px solid #0000ff;
border-right:1px solid #00ff00;
border-top:1px solid #00ff00;
border-bottom:1px solid #0000ff;}
</style>
</head>
<body bgcolor="#00000 0">
<table class="borders" border="0" width="800" cellpadding="4"
cellspacing="0" bgcolor="#efefe f">
<xsl:apply-templates select="menuBar "/>
<tr height="100%">
<td>News Goes Here<br/>
<xsl:apply-templates select="News"/>
</td>
<td class="redText" ><xsl:apply-templates select="MainSec tion"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="News">
<table class="borders" border="0" width="640" cellpadding="4"
cellspacing="0" bgcolor="#ff88c c">
<tr><td></td></tr>
</table>
</xsl:template>
<xsl:template match="MainSect ion">
<span>Hello World!</span>
<p/>
</xsl:template>
<xsl:template match="menuBar" >
<tr>
<td>
<table class="borders" border="0" width="640" cellpadding="4"
cellspacing="0" bgcolor="#ff88c c">
<tr>
<td>register</td>
<td>menu item 1</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
My C# PageLoad Method:
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
datasets.UserIn foDS ds = new datasets.UserIn foDS();
XmlDataDocument dd = new XmlDataDocument (ds);
string xslPath = Server.MapPath( "CommonTemplate .xslt");
StringWriter sw = new StringWriter();
XslTransform xsl = new XslTransform();
xsl.Load(xslPat h);
//Instantiate the XPathDocument Class
//XPathDocument doc = new XPathDocument(x mlPath);
//Instantiate the XslTransform Class
xsl.Transform(d d,null,sw,null) ;
Response.Write( sw.ToString());
}
But I'm getting the following as output:
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-16">
<style type="text/css">
.redText {font-family:arial;co lor:#ff0000;}
.borders {border-left:1px solid #0000ff;
border-right:1px solid #00ff00;
border-top:1px solid #00ff00;
border-bottom:1px solid #0000ff;}
</style>
</head>
<body bgcolor="#00000 0">
<table class="borders" border="0" width="800" cellpadding="4" cellspacing="0" bgcolor="#efefe f">
<tr height="100%">
<td>News Goes Here<br></td>
<td class="redText" >
</td>
</tr>
</table>
</body>
</html>
I am expecting to at least see menubar words, the table under the News area, and the words Hello World in the MainSection. None of those show up. Any ideas? The dataset is just a blank dataset.
Thanks!
Comment