Library tutorials & articles
XML Strengths & Weakness’ with DOM, ASP & XSL
- Introduction
- Benefits & Weaknesses
- XML with ASP
- Converting XML to HTML
Converting XML to HTML
We can maintain XML data on the server and format it into HTML using XSL and then send it to the client. We can do so using any server-side techniques, such as an ASP page. To use XSL, you need to first create an XSL document. This document is a glorified stylesheet, explaining how to display the various XML tags. For example, we could have the following XSL stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML>
<STYLE>
.fr1 { width: 30em; }
BODY { margin:0px; width: 30em;
font-family: Arial, Helvetica,
sans-serif; font-size: smaller;}
P { margin-top: .5em; margin-bottom:
.25em; }
HR { color: #888888; }
.H1 { color: #660033; font-weight: bold;
vertical-align: top; }
.Param { font-size: smaller; vertical-align: top; }
.tagline { font-style: italic; font-size: smaller; text-align:
right; }
.body { text-align: justify; background-color:
#FFFFDD; }
.dingbat { font-family: WingDings; font-style: normal; font-size:
xx-small; }
.person { font-weight: bold; }
.label { font-weight: bold; }
.self { font-style: italic; font-size: smaller;}
#menu { border: 2px solid black; padding: 1em;
background-color: #888833; }
.menutext { color: #FFFFDD; font-family: Times, serif; font-style:
italic;
vertical-align: top; text-align:center;
}
.menuhead { color: #FFFFDD; font-family: Times, serif; font-weight:
bold;
vertical-align: top; text-align:center;
margin-bottom: .5em; }
</STYLE>
<xsl:for-each select="Hi-Tech/Employee">
<TABLE>
<TR><TD Class="H1"><xsl:value-of select="Name" /></TD>
</TR>
<TR>
<xsl:for-each select="Titles">
<TR><TD><xsl:entity-ref name="nbsp"/></TD>
<TD Class="H1"><xsl:value-of select="TitleId"
/></TD>
<TD Class="H1"><xsl:value-of select="royalty"
/></TD>
</TR>
</xsl:for-each></TR>
</TABLE>
</xsl:for-each>
</HTML>
</xsl:template>
</xsl:stylesheet>
This XSL stylesheet can then be loaded and applied using the transformNode method. (For an example of this, see the previous code example, where, at the end, we displayed the XML data from an ADO recordset using an XSL stylesheet.
Well, I hope this article has answered some of your questions on XML. Hopefully you've learned some of the advantages and disadvantages of XML, when it should be used, and how it can be used.
Related articles
Related discussion
-
vb6 generated help file not working in Window 7 and Vista
by Thushan Fernando (1 replies)
-
doctype in xml using c#.net
by madarapurajesh (0 replies)
-
Like statement in Xpath
by madarapurajesh (3 replies)
-
Problem looping through xml file to play a flv video file
by Bozmeister (0 replies)
-
Creating a Windows Service in VB.NET
by davidvanr (108 replies)
Related podcasts
-
LINQ to XML
Scott's been poking around with LINQ to XML and reports his findings to Carl about life with XDocuments and XElements. They also talk about the bridge classes that link (no pun intended) System.Xml and System.Xml.Linq.
Hi
Do you have any experiences about the performance of automate generated HTML by XSL & XML
for example which one is faster:
1. seperate Asp-Sites
2. 1 Asp-Site that was generated by 1 XSL-Site (C# XslTransform)
Thanks
Schneeblitz
This thread is for discussions of XML Strengths & Weakness’ with DOM, ASP & XSL.