您现在的位置: 365建站网 > 建站教程 > XSLT 教程 > XSLT <xsl:apply-templates> 元素

XSLT <xsl:apply-templates> 元素

此节有 171 人学习过     参与评论

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

<xsl:apply-templates> 元素

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

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

请看下面的 XSL 样式表:

</>code

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:template match="/">
  5. <html>
  6. <body>
  7. <h2>My CD Collection</h2>
  8. <xsl:apply-templates/>
  9. </body>
  10. </html>
  11. </xsl:template>
  12. <xsl:template match="cd">
  13. <p>
  14. <xsl:apply-templates select="title"/>
  15. <xsl:apply-templates select="artist"/>
  16. </p>
  17. </xsl:template>
  18. <xsl:template match="title">
  19. Title: <span style="color:#ff0000">
  20. <xsl:value-of select="."/></span>
  21. <br />
  22. </xsl:template>
  23. <xsl:template match="artist">
  24. Artist: <span style="color:#00ff00">
  25. <xsl:value-of select="."/></span>
  26. <br />
  27. </xsl:template>
  28. </xsl:stylesheet>

查看此XML文件查看此XSL文件查看结果

如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛

您可能感兴趣的文章:

发表评论 (171人查看0条评论)
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
昵称:
最新评论
------分隔线----------------------------
XSLT 教程目录

快速入口

· 365软件
· 杰创官网
· 建站工具
· 网站大全

其它栏目

· 建站教程
· 365学习

业务咨询

· 技术支持
· 服务时间:9:00-18:00
365建站网二维码

Powered by 365建站网 RSS地图 HTML地图

copyright © 2013-2024 版权所有 鄂ICP备17013400号