XSLT 教程
1. XSLT 教程 2. XSL 语言 3. XSLT 简介 4. XSLT 浏览器 5. XSLT 转换 6. XSLT <xsl:template> 元素 7. XSLT <xsl:value-of> 元素 8. XSLT <xsl:for-each> 元素 9. XSLT <xsl:sort> 元素 10. XSLT <xsl:if> 元素 11. XSLT <xsl:choose> 元素 12. XSLT <xsl:apply-templates> 元素 13. XSLT 在客户端 14. XSLT 在服务器端 15. XSLT – 编辑 XML 16. XSLT 总结 17. XSLT 实例 18. XSLT 元素参考手册 19. XSLT 函数

XSLT <xsl:apply-templates> 元素

XSLT <xsl:apply-templates> 元素


<xsl:apply-templates> 元素可把一个模板应用于当前的元素或者当前元素的子节点。


<xsl:apply-templates> 元素

<xsl:apply-templates> 元素可把一个模板应用于当前的元素或者当前元素的子节点。

假如我们向 <xsl:apply-templates> 元素添加一个 select 属性,此元素就会仅仅处理与属性值匹配的子元素。我们可以使用 select 属性来规定子节点被处理的顺序。

请看下面的 XSL 样式表:

实例

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="cd"> <p> <xsl:apply-templates select="title"/> <xsl:apply-templates select="artist"/> </p> </xsl:template> <xsl:template match="title"> Title: <span style="color:#ff0000"> <xsl:value-of select="."/></span> <br /> </xsl:template> <xsl:template match="artist"> Artist: <span style="color:#00ff00"> <xsl:value-of select="."/></span> <br /> </xsl:template> </xsl:stylesheet>

55面试教程网 »