<xsl:apply-templates> 元素可把一個模板應用于當前的元素或者當前元素的子節點。
XSLT <xsl:apply-templates> 元素
<xsl:apply-templates> 元素
<xsl:apply-templates> 元素可把一個模板應用于當前的元素或者當前元素的子節點。
假如我們向 <xsl:apply-templates> 元素添加一個 select 屬性,此元素就會僅僅處理與屬性值匹配的子元素。我們可以使用 select 屬性來規定子節點被處理的順序。
請看下面的 XSL 樣式表:
<?xml version="1.0" encoding="ISO-8859-1"?> <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 >查看此XML文件,查看此XSL文件,查看結果。