Global Econometric Populations Levels in XML


XML Data Tree Structure

Click here to see the XML structure of this example.

XML & XSL in Action

Click here to see the XSL formatted display of this example.

The XSL Style Sheet

Notice how this style sheet creates FORM elements in a generic-type manner. This is possible only when the XML tree structure is dynamic in nature. This is actually an important point to note about XML data trees. In general, XML custom tags should be the equivalent of types or data types where the tag attributes or values contain the instances of those data types, ie. the data type instances are the actual data values and the data types are the templates or maps to interpretation of those data values.

<?xml version="1.0"?>

<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:#EEEEEE">

<CENTER>

<H2>World Population Figures in Thousands</H2>

<FORM>

<TABLE CELLPADDING="5" CELLSPACING="1" BORDER="1">

	<TH BGCOLOR="silver"></TH>
	<TH BGCOLOR="silver">1998</TH>
	<TH BGCOLOR="silver">2025</TH>
	<TH BGCOLOR="silver">2050</TH>

	<xsl:for-each select="populationInThousands/world/areas/area">
	<TR>			
		<TD><xsl:value-of select="@where"/></TD>
		<xsl:for-each select="years/year">
			<TD>
				<xsl:element name="INPUT">
					<xsl:attribute name="TYPE">text</xsl:attribute>
					<xsl:attribute name="NAME"><xsl:value-of select="@time"/></xsl:attribute>
					<xsl:attribute name="VALUE"><xsl:value-of select="."/></xsl:attribute>
					<xsl:attribute name="SIZE">10</xsl:attribute>
				</xsl:element>
			</TD>
		</xsl:for-each>
	</TR>
	</xsl:for-each>
	
</TABLE>

</FORM>

</CENTER>

</BODY>
</HTML>

HTML Equivalent

<HTML>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:#EEEEEE">

<CENTER>

<H2>World Population Figures in Thousands</H2>

<FORM>

<TABLE CELLPADDING="5" CELLSPACING="1" BORDER="1">

	<TH BGCOLOR="silver"></TH>
	<TH BGCOLOR="silver">1998</TH>
	<TH BGCOLOR="silver">2025</TH>
	<TH BGCOLOR="silver">2050</TH>

	<TR>			
		<TD>Global</TD>
		<TD><INPUT TYPE="text" NAME="1998" VALUE="5,901,054" SIZE="10"></INPUT></TD>
		<TD><INPUT TYPE="text" NAME="2025" VALUE="7,823,703" SIZE="10"></INPUT></TD>
		<TD><INPUT TYPE="text" NAME="2050" VALUE="8,909,095" SIZE="10"></INPUT></TD>
	</TR>
	
	<TR>			
		<TD>First World</TD>
		<TD><INPUT TYPE="text" NAME="1998" VALUE="1,182,184" SIZE="10"></INPUT></TD>
		<TD><INPUT TYPE="text" NAME="2025" VALUE="1,214,890" SIZE="10"></INPUT></TD>
		<TD><INPUT TYPE="text" NAME="2050" VALUE="1,155,403" SIZE="10"></INPUT></TD>
	</TR>

	<TR>			
		<TD>Second World</TD>
		<TD><INPUT TYPE="text" NAME="1998" VALUE="4,718,869" SIZE="10"></INPUT></TD>
		<TD><INPUT TYPE="text" NAME="2025" VALUE="6,608,813" SIZE="10"></INPUT></TD>
		<TD><INPUT TYPE="text" NAME="2050" VALUE="7,753,693" SIZE="10"></INPUT></TD>
	</TR>

	<TR>			
		<TD>Third World</TD>
		<TD><INPUT TYPE="text" NAME="1998" VALUE="614,919" SIZE="10"></INPUT></TD>
		<TD><INPUT TYPE="text" NAME="2025" VALUE="1,092,623" SIZE="10"></INPUT></TD>
		<TD><<INPUT TYPE="text" NAME="2050" VALUE="1,494,925" SIZE="10"></INPUT></TD>
	</TR>

</TABLE>

</FORM>

</CENTER>

</BODY>
</HTML>