niyue

XSLT技巧–绘制分形图

In programming on 12月 16, 2004 at 4:48 下午

使用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>

发表评论

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

WordPress.com 徽标

您正在使用您的 WordPress.com 账号评论。 注销 /  更改 )

Twitter picture

您正在使用您的 Twitter 账号评论。 注销 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 注销 /  更改 )

Connecting to %s

%d 博主赞过: