我試圖從以下XML中生成html。如何在xslt中給出篩選標記
<students>
<class action="update">2</class>
<section action="update">B</class>
<student>
<name>ravi</name>
<skill action="update">badminton</skill>
</student>
<student action="insert">
<name>gauri</name>
<skill>tennis</skill>
</student>
</students>
我正在寫一個xsl文件來生成下表。
tag subtag action
class update
section update
ravi skill update
gauri insert
我的xsl文件看起來像這樣。
<xsl:template match="/*">
<h2>My CD Collection</h2>
<table>
<tr>
<th>tag</th>
<th>subtag</th>
<th>action</th>
</tr>
<xsl:for-each select="//*">
<xsl:choose>
<xsl:when test="@Action">
<tr>
<td><xsl:value-of select="local-name()"/></td>
<td></td>
<td><xsl:value-of select="@Action"/></td>
</tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</table>
</xsl:template>
但是,這是生成下表。
tag subtag action
class update
section update
skill update
student insert
如何單獨處理學生標籤。請幫忙。我是XSLT新手。
,因爲你'<部分行動=「更新」>乙'。你的XSLT也沒有,因爲你有一個沒有相應的開始標籤的''。另外,你缺少''的結束標記。你能糾正這些,讓我們重新創建你的問題?謝謝! –
@TimC感謝您指出這些。抱歉給你帶來不便。我希望現在的xsl可以重現問題。 –