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
-
handling special character in xslt's
by bussureddy82 (1 replies)
-
Need help in parsing a big XML file with JAVA
by praveen_a_p (0 replies)
-
XML WITH JAVA
by suzan4love (3 replies)
-
A simple way to read an XML file in Java
by ayf (32 replies)
-
how to bind the XML data to the textboxes
by Slicksim (1 replies)
Related podcasts
-
Java Posse #202 - Newscast for Aug 22nd 2008
Newcast for August 22nd, 2008Fully formatted shownotes can always be found at http://javaposse.com Sadly, Java does not run on the Mars LanderThe Golden Gate Project http://research.sun.com/projects/goldengate/Space surveillance radar http://www.sun.com/aboutsun/pr/2008-04/sunflash Google has r...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Trainer JAVA
in AMSTERDAM (€50K-€90K per annum) -
Applicatie ontwikkelaar binnen Defensie
in Amsterdam (£50K-£90K per annum) -
Ervaren SAP XI Specialist
in Amsterdam (€50K-€90K per annum)
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.