<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly'>
<s:attribute type='EmployeeID'/>
<s:attribute type='LastName'/>
<s:attribute type='FirstName'/>
<s:extends type='rs:rowbase'/>
</s:ElementType>
<s:AttributeType name='EmployeeID' rs:number='1'>
<s:datatype dt:type='int' dt:maxLength='4'
rs:precision='10'
rs:fixedlength='true'
rs:maybenull='false'/>
</s:AttributeType>
<s:AttributeType name='LastName'
rs:number='2'
rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' dt:maxLength='20'/>
</s:AttributeType>
<s:AttributeType name='FirstName'
rs:number='3'
rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' dt:maxLength='10'/>
</s:AttributeType>
</s:Schema>
<rs:data>
<z:row EmployeeID='1' LastName='Davolio' FirstName='Nancy'/>
<z:row EmployeeID='2' LastName='Fuller' FirstName='Andrew'/>
<z:row EmployeeID='3' LastName='Leverling' FirstName='Janet'/>
</rs:data>
</xml>
Figure 6 Rendering XML with HTML
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"
xmlns:html="http://www.w3.org/TR/REC-html40"
result-ns=""
language="JScript">
<xsl:template match="/">
<html>
<head>
<title>RowsetSchema</title>
<style>
.stdText {
font-Family:verdana;
font-Size: 9px;
}
</style>
</head>
<body>
<table width="100%" border="1">
<xsl:for-each select="xml/s:Schema/s:ElementType/s:attribute">
<th class="stdText"><xsl:value-of select="@type" /></th>
</xsl:for-each>
<xsl:for-each select="xml/rs:data/z:row">
<tr>
<xsl:for-each select="@*">
<td class="stdText" valign="top"><xsl:value-of match="@*"/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Figure 9 A Record in XML
?<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Tree.xsl"?>
<recordset total="9">
<row id="1">
<field name="EmployeeID">1</field>
<field name="LastName">Davolio</field>
<field name="FirstName">Nancy</field>
<field name="Title">Sales Representative</field>
<field name="TitleOfCourtesy">Ms.</field>
<field name="HireDate">5/1/92</field>
<field name="City">Seattle</field>
<field name="Notes">Education includes a BA in psychology from Colorado
State University in 1970. She also completed "The Art of the Cold Call."
Nancy is a member of Toastmasters International.</field>
</row>
</recordset>
Figure 12 tree.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"
xmlns:html="http://www.w3.org/TR/REC-html40"
result-ns=""
language="JScript">
<xsl:template match="/">
<html>
<head>
<title>Tree of Employees</title>
<style>
.div {
background-color:beige;
}
</style>
</head>
<script language="jscript">
function Expand(id) {
state = document.all(id).style.display;
if (state == "")
document.all(id).style.display = "none";
else
document.all(id).style.display = "";
}
function hilite() {
obj = window.event.srcElement;
if (obj.id == "hilite")
obj.style.color = "red";
}
function unhilite() {
obj = window.event.srcElement;
if (obj.id == "hilite")
obj.style.color = "";
}
</script>
<body onmouseover="hilite()" onmouseout="unhilite()">
<table width="100%" border="1">
<xsl:for-each select="recordset">
<xsl:apply-templates select="row"/>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="row">
<tr>
<td valign="top">
<b>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:eval>FormatFuncName()</xsl:eval></xsl:attribute>
<xsl:attribute name="id">hilite</xsl:attribute>
<xsl:eval>FormatName()</xsl:eval>
</xsl:element>
</b>
<xsl:element name="div">
<xsl:attribute name="id">a<xsl:value-of select="@id" /></xsl:attribute>
<xsl:attribute name="style">display:none</xsl:attribute>
<xsl:attribute name="class">div</xsl:attribute>
<xsl:eval>FormatText()</xsl:eval>
<br/><b>Personal Notes: </b>
<i><xsl:eval>FormatNotes()</xsl:eval></i>
</xsl:element>
</td>
</tr>
</xsl:template>
<xsl:script language="JScript">
<![CDATA[
EMPLOYEEID = 0
LASTNAME = 1
FIRSTNAME = 2
COURTESY = 4
TITLE = 3
HIRED = 5
CITY = 6
NOTES = 7
function FormatName() {
list = this.selectNodes("field");
if(list.length == 0) {
return "No info found.";
} else {
str = "";
str = list.item(EMPLOYEEID).text + " - " +
list.item(COURTESY).text + " " +
list.item(FIRSTNAME).text + " " +
list.item(LASTNAME).text + " ";
return str;
}
}
function FormatText() {
list = this.selectNodes("field");
if(list.length == 0) {
return "No info found.";
} else {
str = "Hired on ";
str = list.item(HIRED).text + ". Office of " +
list.item(CITY).text;
return str;
}
}
function FormatFuncName() {
return "javascript:Expand(\"a" + this.attributes.getNamedItem("id").text + "\")";
}
function FormatTitle() {
list = this.selectNodes("field");
if(list.length == 0) {
return "No info found.";
} else {
str = "";
str = list.item(TITLE).text + " hired on: " +
list.item(HIRED).text;
return str;
}
}
function FormatCity() {
list = this.selectNodes("field");
if(list.length == 0) {
return "No info found.";
} else {
str = "";
str = list.item(CITY).text;
return str;
}
}
function FormatNotes() {
list = this.selectNodes("field");
if(list.length == 0) {
return "No info found.";
} else {
str = "";
str = list.item(NOTES).text;
return str;
}
}
]]>
</xsl:script>
</xsl:stylesheet>