|
(1) Code from a simple database-driven Web site showing the method by which a Web page calls for content from an underlying database (highlights indicate code discussed in essay):
//Connects the Web page to an Access database named "liu-images.mdb,"
//Creates data object through a SQL query "Select" statement
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=E:\databases/liu-images.mdb";
Recordset1.Source = "SELECT * FROM Artists
ORDER BY LastName, FirstName, Dates, Nation";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 3;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
//HTML table whose data is pulled through the data connection from records
in the database
//The table is set within a Repeat procedure that repeats the process for every
record in the database
(2) Code for the XSLT stylesheet "Hypertext_Fiction.xsl" (from my "Hypertext Fiction Tracker" demo) showing the method by which a Web page calls for content from an underlying XML document. (Highlights indicate code discussed above.)
// Called by the XML document "falco_instance.xml" to transform
XML into HTML for Web;
// Uses <SPAN> tags to format for HTML the content found in "nodes"
in the XML document;
// Note the analogy between the XPATH language "select" statement
that locates nodes (e.g.
// "select="REGISTER/WORK" and the SQL "select" statement
<?xml version="1.0"?>
<!-- File Name: Hypertext_Fiction.xsl -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Hypertext Fiction Tracker</TITLE>
</HEAD>
<BODY>
<SPAN STYLE="font-family:arial, Helvetica, sans-serif;
font-size:14px">
<DIV align="center">
<FONT size="+4">Hypertext Fiction Tracker</FONT><BR/>
<FONT size="+3">Conceptual Demo of XML
Application</FONT><BR/>
<FONT size="+2">(Alan Liu; last rev. Feb.
18, 2002)</FONT>
</DIV><BR/>
<SPAN STYLE="font-size:130%; font-weight:900">
Title of Work:
</SPAN>
<SPAN STYLE="font-size:130%; font-weight:900;
color:red">
"<xsl:value-of select="WORK_TITLE"/>"
</SPAN><BR/>
<SPAN STYLE="font-size:130%;font-weight:900">
Author:
</SPAN>
<SPAN STYLE="font-size:130%; font-weight:900;
color:red">
<xsl:value-of select="AUTHOR"/>
</SPAN><BR/>
<SPAN STYLE="font-size:130%;font-weight:900">
Date of Publication:
</SPAN>
<SPAN STYLE="font-size:130%; color:red">
<xsl:value-of select="DATE"/>
</SPAN><BR/>
<SPAN STYLE="font-size:130%;font-weight:900">
Media Format:
</SPAN>
<SPAN STYLE="font-size:130%; color:red">
<xsl:value-of select="MEDIA"/>
</SPAN><BR/>
<SPAN STYLE="font-size:130%;font-weight:900">
URL:
</SPAN>
<SPAN STYLE="color:red">
<A><xsl:attribute name="href">
<xsl:value-of select="WORK_URL"/>
</xsl:attribute>
<xsl:value-of select="WORK_URL"/>
</A><BR/>
</SPAN><BR/><BR/><HR/>
<SPAN STYLE="font-size:130%; font-weight:900;
color:red">
Plot Strands:
</SPAN><HR/><BR/>
<xsl:for-each select="/REGISTER/WORK/PLOT/STRAND">
<SPAN STYLE="font-size:130%; font-weight:900;
color:blue">
<xsl:value-of select="STRAND_TITLE"/>
</SPAN><BR/><BR/>
<TABLE width="80%" border="1"
align="center" bordercolordark="FFFFFF" bordercolor="#999999">
<TR>
<TD width="15%"><SPAN STYLE="font-weight:800;
color:blue">Lexia Title: </SPAN></TD>
<TD><SPAN STYLE="font-weight:800; color:blue">
<xsl:value-of select="LEXIA_TITLE"/></SPAN></TD>
</TR>
<TR>
<TD><SPAN STYLE="font-weight:800">Characters:
</SPAN></TD>
<TD><xsl:value-of
select="CHARACTERS"/></TD>
</TR>
<TR>
<TD><SPAN STYLE="font-weight:800">Mode:
</SPAN></TD>
<TD><xsl:value-of
select="MODE"/></TD>
</TR>
<TR>
<TD><SPAN STYLE="font-weight:800">Description
or Keywords: </SPAN></TD>
<TD><xsl:value-of
select="KEYWORDS"/></TD>
</TR>
<TR>
<TD><SPAN STYLE="font-weight:800">Lexia
URL: </SPAN></TD>
<TD><A>
<xsl:attribute name="href"><xsl:value-of
select="LEXIA_URL"/></xsl:attribute>
<xsl:attribute name="target">"2"</xsl:attribute>
<xsl:value-of select="LEXIA_URL"/>
</A></TD>
</TR>
</TABLE><BR/><BR/>
</xsl:for-each>
<HR/>
</xsl:for-each>
</xsl:for-each>
</SPAN>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>