niyue

XSLT技巧–绘制分形图

In programming on December 16, 2004 at 4:48 PM

使用IE 6.0(Firefox还不完全支持XSLT可惜 : < )浏览fractal.xml,就能够看到漂亮的分形图。fractal.xml

<?xml version=”1.0″?>
<?xml-stylesheet type=”text/xsl” xhref=”http://blogger.org.cn/blog/fractal.xsl&#8221; mce_href=”http://blogger.org.cn/blog/fractal.xsl&#8221;?>
<fractal depth=”6″ color=”orange” size=”3″/>

fractal.xsl

<?xml version=”1.0″?>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“>

<xsl:template match=”fractal”>
<xsl:param name=”depth” select=”@depth”/>
<table border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr>
<td>
<xsl:call-template name=”iterate”>
<xsl:with-param name=”depth” select=”$depth”/>
</xsl:call-template>
</td>
</tr>
<tr>
<td>
<xsl:call-template name=”iterate”>
<xsl:with-param name=”depth” select=”$depth”/>
</xsl:call-template>
</td>
<td>
<xsl:call-template name=”iterate”>
<xsl:with-param name=”depth” select=”$depth”/>
</xsl:call-template>
</td>
</tr>
</table>
</xsl:template>

<xsl:template name=”iterate”>
<xsl:param name=”depth”/>
<xsl:choose>
<xsl:when test=”$depth > 0″>
<xsl:apply-templates select=”.”>
<xsl:with-param name=”depth” select=”$depth+(-1)”/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<table cellpadding=”0″ cellspacing=”0″ border=”0″ height=”{@size}” width=”http://blogger.org.cn/blog/{@size}”>
<tr><td bgcolor=”http://blogger.org.cn/blog/

{@color}”></td></tr>
</table>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: