-
(change: )
以上的代码很容易理解,关键是采用选择语句(for-each select)在XML树结构中进行选择,并把得到的结果树(Result Tree)包容于HTML中(value-of select).其实这只是简单的XSL语句.XSL的脚本语言叫做ECMAScript,它是在JavaScript的基础上发展的。如果我们要改变stock-sorter.xml的表现,只要在stlye sheet的href中指定另外的XSL文件。 在XSL的规范定义了XML的匹配模板(Template),设置匹配字符,则处理时将从XML的根节点(Root Node)搜索匹配的节点.如:.通常构成HTML格式的模板,它可以只是XSL的一部分。您还可以写XSL的脚本,举个示例: 还可以加XSL的注释,如: 让我们给出另一个较为复杂的例子,并据此进一步学习XSL: Complex.xsl: <?xml version="1.0"?>
for
Average change:
averageChange(this)
Total volume:
totalVolume(this)
| |
Click on the column headers to sort by that field. Demonstration of custom formatting of data typed values and local reapplication of the stylesheet. Stocks losing more than 5% indicated in red. Stocks gaining value indicated in green. |
Company
Symbol
Price
Change
%Change
Volume
updown
formatDate(this.nodeTypedValue, "MMMM dd',' yyyy") at formatTime(this.nodeTypedValue, "hh:mm tt")formatNumber(this.nodeTypedValue, "$0.00")+formatNumber(this.nodeTypedValue, "0.0")% formatNumber(this.nodeTypedValue * 1000000, "#,###,###") 如果你要显示中文,你只要在XML和XSL文件的的开头分别加上:<?xml version="1.0" encoding="gb2312"?>即可.试试看!