Population Extract 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

The XSL style sheet shown below will break up the populations by the sizes of those populations.

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

<H2>Populations</H2>

<TABLE>

<xsl:for-each select="populationInThousands/world/continents/continent/countries/country">

	<TR>

		<xsl:choose>

			<xsl:when test="year1998[. $gt$ 1000000]">
				<TD><xsl:value-of select="@name"/> is <SPAN STYLE="font-weight:bold; color:red"><xsl:value-of select="year1998"/></SPAN></TD>
			</xsl:when>

			<xsl:when test="year1998[. $gt$ 100000]">
				<TD><xsl:value-of select="@name"/> is <SPAN STYLE="font-weight:bold; color:green"><xsl:value-of select="year1998"/></SPAN></TD>
			</xsl:when>

			<xsl:otherwise>
				<TD><xsl:value-of select="@name"/> is <xsl:value-of select="year1998"/></TD>
			</xsl:otherwise>

		</xsl:choose>

	</TR>

</xsl:for-each>

</TABLE>

</BODY>
</HTML>