![]() | |||||||||||||||||||||
![]() |
|
|
Putting it all together Once we have created the XSL to go with the XML we need to put the to together to form a webpage. We can do this utilizing a server side function. We set the two objects in ASP that calls the XMLDOM Object.
<%
'Load the XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("example.xml"))
'Load the XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("example.xsl"))
Response.Write(xml.transformNode(xsl))
%>
In this particular example we are loading two files, example.xml and example.xsl. We could however, have pulled the XML from a different source, say a database or a different website. The same is true of the XSL. We could even pull it from the same file, however, it may be easier to keep the three files separated so if there is a problem with one that is the only file that is affected. Once we have placed these components together this is the resulting HTML:
<body> <html> <table width="90%" border="0" cellspacing="3"> <tr><td colspan="3" bgcolor="#336699"><font color="white" face="arial"><b><i>ASP.net</i></b></font></td></tr> <tr><td width="2%"></td><td colspan="2" bgcolor="#CCCCCC"><font size="2" face="arial"><b>Introduction</b></font></td></tr> <tr><td width="2%"></td><td width="5%"></td><td><font size="2" face="arial"><b> <A href="asp.net"> An Overview in the Differences Between ASP and ASP.net </A> </b><i></i></font></td></tr> <tr><td width="2%"></td><td width="5%"></td><td> <table border="0"> <tr><td width="5%"></td><td><font size="1" face="arial"> <A href="asp.net/index.aspx"> Section 1: Introduction </A> </font></td></tr> <tr><td width="5%"></td><td><font size="1" face="arial"> <A href="asp.net/aspnetdif.aspx"> Section 2: ASP.net Differences 1 </A> </font></td></tr> <tr><td width="5%"></td><td><font size="1" face="arial"> <A href="asp.net/aspnetdif2.aspx"> Section 3: ASP.net Differences 2 </A> </font></td></tr> <tr><td width="5%"></td><td><font size="1" face="arial"> <A href="asp.net/aspnetdiffinal.aspx"> Section 4: Final Differences and Conclusion </A> </font></td></tr> </table></td></tr></table> </body> </html> There is Strength in Numbers Of course, the real strengths of XML lie in its ability to be pulled from sources across the internet. It will allow people to collaborate in new ways. Interfaces to various websites are already being built and utilized. Our own Tutorial-web.com Bookworm, for instance, allows data to be displayed from Amazon.com in a format that is consistant with the rest of the website. In the future, hopefully, more webmasters will allow libraries of data to be exchanged in this way.
|
Section 2: XSL Power! Section 3: Same Difference Section 4: XSL+XML+ASP=HTML
| ||||||||||||||||||||||