<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jennal's Blog &#187; xslt</title>
	<atom:link href="http://jennal.cn/category/xml/xslt/feed/" rel="self" type="application/rss+xml" />
	<link>http://jennal.cn</link>
	<description>Jennal的技术博客</description>
	<lastBuildDate>Thu, 05 Jan 2012 14:02:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>XSLT format-number() 函数</title>
		<link>http://jennal.cn/2008/11/02/xslt-format-number-%e5%87%bd%e6%95%b0/</link>
		<comments>http://jennal.cn/2008/11/02/xslt-format-number-%e5%87%bd%e6%95%b0/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 06:02:12 +0000</pubDate>
		<dc:creator>Jennal</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://jennal.cn/?p=79</guid>
		<description><![CDATA[定义和用法
format-number() 函数用于把数字转换为字符串。
语法
string format-number(number,format,[decimalformat])
参数
参数 	描述
number 	必需。规定要格式化的数字。
format 	必需。规定格式化模式。这是用在格式化模式中的字符：
    * # (表示数字。例如：####)
    * 0 (表示“.”字符前面和后面的零。例如：0000.00)
    * . (小数点的位置。例如：###.##)
    * , (千的组分隔符。例如：###,###.##)
    * % (把数字显示为百分比。例如：##%)
    * ; (模式分隔符。第一个模式用于正数，第二个模式用于负数。)
decimalformat 	可选。十进制格式名称。
例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&#60;?xml version=&#34;1.0&#34; encoding=&#34;ISO-8859-1&#34;?&#62;
&#60;xsl:stylesheet version=&#34;1.0&#34;
xmlns:xsl=&#34;http://www.w3.org/1999/XSL/Transform&#34;&#62;
&#160;
&#60;xsl:template match=&#34;/&#34;&#62;
&#60;html&#62;
&#60;body&#62;
&#60;xsl:value-of select='format-number(500100, &#34;#.00&#34;)' /&#62;
&#60;br /&#62;
&#60;xsl:value-of select='format-number(500100, &#34;#.0&#34;)' /&#62;
&#60;br /&#62;
&#60;xsl:value-of [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="数学运算和XSLT" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://jennal.cn/wp-content/themes/compositio/images/avatar-replace.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">数学运算和XSLT</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="漫画下载器 v1.5" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F05%2F17%2F%25E6%25BC%25AB%25E7%2594%25BB%25E4%25B8%258B%25E8%25BD%25BD%25E5%2599%25A8-v1-5%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/02/24/2911518.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">漫画下载器 v1.5</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="漫画下载器 v1.6.5" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2011%2F04%2F05%2F%25E6%25BC%25AB%25E7%2594%25BB%25E4%25B8%258B%25E8%25BD%25BD%25E5%2599%25A8-v1-6-5%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/04/06/5053116.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">漫画下载器 v1.6.5</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="强烈谴责盗版！" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2011%2F02%2F17%2F%25E5%25BC%25BA%25E7%2583%2588%25E8%25B0%25B4%25E8%25B4%25A3%25E7%259B%2597%25E7%2589%2588%25EF%25BC%2581%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/02/24/2910872.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">强烈谴责盗版！</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>定义和用法</p>
<p>format-number() 函数用于把数字转换为字符串。<br />
语法</p>
<p>string format-number(number,format,[decimalformat])</p>
<p>参数<br />
参数 	描述<br />
number 	必需。规定要格式化的数字。<br />
format 	必需。规定格式化模式。这是用在格式化模式中的字符：</p>
<p>    * # (表示数字。例如：####)<br />
    * 0 (表示“.”字符前面和后面的零。例如：0000.00)<br />
    * . (小数点的位置。例如：###.##)<br />
    * , (千的组分隔符。例如：###,###.##)<br />
    * % (把数字显示为百分比。例如：##%)<br />
    * ; (模式分隔符。第一个模式用于正数，第二个模式用于负数。)</p>
<p>decimalformat 	可选。十进制格式名称。</p>
<p>例子</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;ISO-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">'format-number(500100, &quot;#.00&quot;)'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">'format-number(500100, &quot;#.0&quot;)'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">'format-number(500100, &quot;###,###.00&quot;)'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">'format-number(0.23456, &quot;##%&quot;)'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">'format-number(500100, &quot;#######&quot;)'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="数学运算和XSLT" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://jennal.cn/wp-content/themes/compositio/images/avatar-replace.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">数学运算和XSLT</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="漫画下载器 v1.3" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F03%2F05%2F%25E6%25BC%25AB%25E7%2594%25BB%25E4%25B8%258B%25E8%25BD%25BD%25E5%2599%25A8-v1-3%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/02/24/2911529.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">漫画下载器 v1.3</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="有道难题资格赛心得" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F06%2F01%2F%25E6%259C%2589%25E9%2581%2593%25E9%259A%25BE%25E9%25A2%2598%25E8%25B5%2584%25E6%25A0%25BC%25E8%25B5%259B%25E5%25BF%2583%25E5%25BE%2597%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/02/24/2911611.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">有道难题资格赛心得</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[转]Web 设计与开发者必须知道的 15 个站点" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F25%2Fweb-designer-developer-should-know-15-sites%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/08/06/21297230.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[转]Web 设计与开发者必须知道的 15 个站点</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://jennal.cn/2008/11/02/xslt-format-number-%e5%87%bd%e6%95%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>数学运算和XSLT</title>
		<link>http://jennal.cn/2008/11/02/%e6%95%b0%e5%ad%a6%e8%bf%90%e7%ae%97%e5%92%8cxslt/</link>
		<comments>http://jennal.cn/2008/11/02/%e6%95%b0%e5%ad%a6%e8%bf%90%e7%ae%97%e5%92%8cxslt/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 04:54:29 +0000</pubDate>
		<dc:creator>Jennal</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://jennal.cn/?p=77</guid>
		<description><![CDATA[　　XSLT对XPath的数学性能的完全支持使人们可以做所有基本类型的算法或者更多！让我们看一下一个通过使用下面文件的值来示范这些性能的样式表：

1
2
3
4
5
&#60;numbers&#62;
&#60;x&#62;4&#60;/x&#62;
&#60;y&#62;3.2&#60;/y&#62;
&#60;z&#62;11&#60;/z&#62;
&#60;/numbers&#62;

　　样式表的A到N每行均进行着（或者试图进行）一个不同的计算。这些计算使用上面文件中给出的数字和其他一些或者是样式表中固定的代码或者是从函数中返回的数值得到的值。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
&#60;xsl:stylesheet xmlns:xsl=&#34;http://www.w3.org/1999/XSL/Transform&#34;
version=&#34;1.0&#34;&#62;
&#60;xsl:output method=&#34;xml&#34; omit-xml-declaration=&#34;yes&#34;/&#62;
&#160;
&#60;xsl:template match=&#34;numbers&#34;&#62;
A. 4 + 3.2 = &#60;xsl:value-of select=&#34;x + y&#34;/&#62;
B. 3.2 - 4 = &#60;xsl:value-of select=&#34;y - x&#34;/&#62;
C. 4 * 3.2 = &#60;xsl:value-of select=&#34;x * y&#34;/&#62;
D. 11/3.2 = &#60;xsl:value-of select=&#34;z div y&#34;/&#62;
E. 4 + 3.2 * 11 = &#60;xsl:value-of select=&#34;x+y*z&#34;/&#62;
F. (4 + 3.2) * 11 = &#60;xsl:value-of select=&#34;(x+y)*z&#34;/&#62;
G. 11 mod 4 = [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="XSLT format-number() 函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://jennal.cn/wp-content/themes/compositio/images/avatar-replace.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">XSLT format-number() 函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="漫画下载器 v1.6.6" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2011%2F05%2F01%2F%25E6%25BC%25AB%25E7%2594%25BB%25E4%25B8%258B%25E8%25BD%25BD%25E5%2599%25A8-v1-6-6%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/07/28690876.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">漫画下载器 v1.6.6</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="漫画下载器 v1.1" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F01%2F05%2F%25E6%25BC%25AB%25E7%2594%25BB%25E4%25B8%258B%25E8%25BD%25BD%25E5%2599%25A8-v1-1%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/02/24/2911539.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">漫画下载器 v1.1</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="C語言教程 — （一）環境配置" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F08%2F26%2Fc%25E8%25AA%259E%25E8%25A8%2580%25E6%2595%2599%25E7%25A8%258B-%25EF%25BC%2588%25E4%25B8%2580%25EF%25BC%2589%25E7%2592%25B0%25E5%25A2%2583%25E9%2585%258D%25E7%25BD%25AE%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/02/24/2911305.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">C語言教程 — （一）環境配置</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>　　XSLT对XPath的数学性能的完全支持使人们可以做所有基本类型的算法或者更多！让我们看一下一个通过使用下面文件的值来示范这些性能的样式表：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;numbers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;x<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/x<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;y<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/y<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;z<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>11<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/z<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/numbers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>　　样式表的A到N每行均进行着（或者试图进行）一个不同的计算。这些计算使用上面文件中给出的数字和其他一些或者是样式表中固定的代码或者是从函数中返回的数值得到的值。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:output</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;xml&quot;</span> <span style="color: #000066;">omit-xml-declaration</span>=<span style="color: #ff0000;">&quot;yes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;numbers&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
A. 4 + 3.2 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;x + y&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
B. 3.2 - 4 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;y - x&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
C. 4 * 3.2 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;x * y&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
D. 11/3.2 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;z div y&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
E. 4 + 3.2 * 11 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;x+y*z&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
F. (4 + 3.2) * 11 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;(x+y)*z&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
G. 11 mod 4 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;z mod x&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
H. 4 + 3.2 + 11 = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;sum(*)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
I. floor(3.2) = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;floor(y)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
J. ceiling(3.2) = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;ceiling(y)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
K. round(3.2) = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;round(y)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
L. 11 + count(*) = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;11+count(*)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
M. 3.2 + string-length(&quot;3.2&quot;) =
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;y + string-length(y)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
N. 11 + &quot;hello&quot; = <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;z + 'hello'&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>在我们讨论每一行具体做什么之前，让我们先看一下将样式表应用到数字文件中的结果。</p>
<p>A. 4 + 3.2 = 7.2<br />
B. 3.2 &#8211; 4 = -0.8<br />
C. 4 * 3.2 = 12.8<br />
D. 11/3.2 = 3.4375<br />
E. 4 + 3.2 * 11 = 39.2<br />
F. (4 + 3.2) * 11 = 79.2<br />
G. 11 mod 4 = 3<br />
H. 4 + 3.2 + 11 = 18.2<br />
I. floor(3.2) = 3<br />
J. ceiling(3.2) = 4<br />
K. round(3.2) = 3<br />
L. 11 + count(*) = 14<br />
M. 3.2 + string-length(&#8220;3.2&#8243;) =<br />
6.2<br />
N. 11 + &#8220;hello&#8221; = NaN</p>
<p>　　这个样式表对源树中的numbers元素具有一个单一的模板规则。这个模板有一系列的 xsl:value-of 指令，它们用来选择属性使用numbers元素的x、y和z子元素的数值去进行各种不同的数学计算。类似的这些数学公式可以使用XPath的全部功能来表示哪些元素或属性具有他们需要的数字；但是，这个样式表更加注重于说明与使用奇特的XPath表达式从一个文件的余部找回元素和属性相比它可用的数学运算的范围。<br />
　　模板的行A将x的值（4）加到y的值(3.2)上并将他们的和7.2放到结果树中。这是非常简单的、直观的，并显示了并不需要限制在样式表数学中为整数。<br />
　　行B从3.2中减掉了4得到结果为-0.8。负数并没有给XSLT处理器带来任何的困难。<br />
　　警告： 对某些XSLT处理器，十进制数字的使用可能引入一个微小的误差。例如，这个例子中的&#8221;3.2 &#8211; 4&#8243;在有些处理器中得到的结果为&#8221;-.7999999999999998&#8243;。 .0000000000000002的误差很小，但从根本上说明数学并不是XSLT的强项。<br />
　　行C用4乘3.2，使用星号作为乘法运算符，其结果为12.8。<br />
　　行D用3.2除z元素(11)，说明了一个XSLT处理器执行浮点除法运算的能力。尽管大多数的编程语言在传统上使　　用斜线字符（/）表示除法运算符，但是Xpath已经将斜线字符用来分段Xpath位置路径（例如, wine/vintage 表示了vintage 元素为 wine 元素的子元素）。因此，Xpath和XSLT用字符&#8221;div&#8221; 表示除法。<br />
　　行E和F显示了圆括号与在正常的数学符号中具有同样的操作优先权：不使用圆括号，先乘后加，所以4 + 3.2 * 11 = 4 + 35.2。对&#8221;4+3.2&#8243;使用圆括号后，先进行加法运算，所以(4 + 3.2) * 11 = 7.2 * 11。<br />
　　行G示范了mod 运算符，它得到了两数相除的余数。例中为11 mod 4 结果为3，因为11除以4得2余3。这个运算符主要用来检查一个数是否能被另一个数均分；即检查大数mod小数是否等于0。<br />
　　行H示范了sum() 函数。用节点列表作为参数，它加和了列表中所有节点的数值。在本例中星号的意思是&#8221;范围节点内的所有子节点&#8221;&#8211;即numbers元素的x, y和z 子元素。<br />
　　行I和J示范了floor() 和ceiling() 函数。如果它们传入的参数为整数，它们即返回该整数。如果传入floor() 一个非整数，将返回一个小于该数的最大整数。本例中为floor(3.2)结果为3。ceiling函数将返回大于该数（非整数）的最小整数；例中 ceiling(3.2)结果为4。<br />
　　行K的round()函数把一个非整数舍入为一个最接近的整数。 当传入参数为3.2时，返回值为3；传入3.5或3.6时，它的返回值将变为4。<br />
　　行L具体表现了另一个Xpath函数：count()，它将返回作为参数传给它的节点集的个数。Xpath提供几个函数，当数学上不明确时，返回数值并可以用于各种计算：count(), last(), position()和string-length()。行M示范了string-length()，它将返回该字符串的长度。<br />
　　行N显示了当试图对一些不是数字的东西执行数学运算时得到的结果：当11加上字符串&#8221;hello&#8221;时，得到的结果为字符串&#8221;NaN&#8221;，即&#8221;Not a Number.&#8221;的缩写。当你把一个数字作为一个元素的内容或者是属性值，然后用它来进行计算，将不能保证它真正的是一个数字，所以XSLT明确定义了不能实行的情况的状态，使之更加容易的检测和处理你的代码。<br />
　　XSLT是用来处理文本，而不是数字；但是你可以用作为XSLT一部分提供的数学运算符来构建和执行更多复杂的计算。例如，下面的样式表，它可以接受任何文件作为输入，计算 pi的值。其结果的精度依赖于迭代变量的值。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:output</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Compute pi. Based on Leibniz's algorithm that</span>
<span style="color: #808080; font-style: italic;">pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11... which I did as</span>
<span style="color: #808080; font-style: italic;">pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11...</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:variable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;iterations&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;80000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pi&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- named template called by main template below --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;i&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;piValue&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:choose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- If there are more iterations to do, add the passed</span>
<span style="color: #808080; font-style: italic;">value of pi to another round of calculations. --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:when</span> <span style="color: #000066;">test</span>=<span style="color: #ff0000;">&quot;$i &amp;lt;= $iterations&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:call-template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pi&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:with-param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;i&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$i + 4&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:with-param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;piValue&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$piValue + (4 div $i) - (4 div ($i + 2))&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:call-template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:when<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- If no more iterations to do, add</span>
<span style="color: #808080; font-style: italic;">computed value to result tree. --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:otherwise<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$piValue&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:otherwise<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:choose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:call-template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pi&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>　　循环通过利用一个递归的命名模板（named template）来实现。根据迭代设置显示，该样式表得到的结果为：<br />
3.1415676535897985<br />
　　经过多次迭代，结果仅仅精确到小数点后的第四位数字。当然如果你想认真地计算PI的值，有更多合适的编程语言。但是知道了在必要的时候可以使用XSLT来做一些相对复杂的数学运算还是很不错的。 </p>
<p>补充一个sum函数的用法：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span>   <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;sum(/Price[normalize-space(.)   !=''])&quot;</span>   <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="XSLT format-number() 函数" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2Fxslt-format-number-%25E5%2587%25BD%25E6%2595%25B0%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://jennal.cn/wp-content/themes/compositio/images/avatar-replace.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">XSLT format-number() 函数</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="漫画下载器 v1.6.8" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2011%2F11%2F21%2F%25E6%25BC%25AB%25E7%2594%25BB%25E4%25B8%258B%25E8%25BD%25BD%25E5%2599%25A8-v1-6-8%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/11/21/11189295.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">漫画下载器 v1.6.8</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Mac OS X快捷键大全" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F11%2F30%2Fmac-os-x%25E5%25BF%25AB%25E6%258D%25B7%25E9%2594%25AE%25E5%25A4%25A7%25E5%2585%25A8%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/02/24/2911859.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Mac OS X快捷键大全</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="漫画下载器 v1.6.7" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2011%2F09%2F11%2F%25E6%25BC%25AB%25E7%2594%25BB%25E4%25B8%258B%25E8%25BD%25BD%25E5%2599%25A8-v1-6-7%2F&from=http%3A%2F%2Fjennal.cn%2F2008%2F11%2F02%2F%25E6%2595%25B0%25E5%25AD%25A6%25E8%25BF%2590%25E7%25AE%2597%25E5%2592%258Cxslt%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/09/11/30021135.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 15px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">漫画下载器 v1.6.7</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://jennal.cn/2008/11/02/%e6%95%b0%e5%ad%a6%e8%bf%90%e7%ae%97%e5%92%8cxslt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

