我只是在学习XML以及如何使用XSL文件.在XSL文件中,我发现了以下术语:
xsl:template match="/"
Run Code Online (Sandbox Code Playgroud)
这代表什么?我可以用什么而不是/?我可以写table或任何其他HTML标签而不是/?
对于这样一个非常简单的XML:
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
</catalog>
Run Code Online (Sandbox Code Playgroud)
和一个简单的xslt:
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
为什么会产生如下输出:
Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985
Hide your heart
Bonnie Tyler
UK
CBS Records
9.90
1988
Greatest Hits
Dolly Parton
USA
RCA
9.90
1982
Run Code Online (Sandbox Code Playgroud)
所有XML标签都去了哪里?我应该<xsl:apply-templates/>用<xsl:copy>标签包围以
使其工作吗?