XSLT Apply
<xsl:apply-templates> 元素可把一个模板应用于当前的元素或者当前元素的子节点。
<xsl:apply-templates> 元素
<xsl:apply-templates> 元素可把一个模板应用于当前的元素或者当前元素的子节点。
假如我们向 <xsl:apply-templates> 元素添加一个 select 属性,此元素就会仅仅处理与属性值匹配的子元素。我们可以使用 select 属性来规定子节点被处理的顺序。
请看下面的 XSL 样式表:
实例
<?xmlversion="1.0"encoding="UTF-8"?><xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:templatematch="/"><html><body><h2>My CD Collection</h2><xsl:apply-templates/></body></html></xsl:template><xsl:templatematch="cd"><p><xsl:apply-templatesselect="title"/><xsl:apply-templatesselect="artist"/></p></xsl:template><xsl:templatematch="title">
Title: <spanstyle="color:#ff0000"><xsl:value-ofselect="."/></span><br/></xsl:template><xsl:templatematch="artist">
Artist: <spanstyle="color:#00ff00"><xsl:value-ofselect="."/></span><br/></xsl:template></xsl:stylesheet>
尝试一下 »