我寫的XSLT代碼格式化sample.xml中(見下文)如何在xslt中使用「if」來表示角色?
我所試圖做的是,在我的Sample.xslt文件,我檢查用於type = MP4和顯示名稱(在這種情況下,應顯示的名稱是RequiredFileName。總之,我想,當我將XSLT我的XML文件,我讓我的MP4文件的名稱。
sample.xml中
<assets>
<asset id="01" path="//my_computer/path" name="testfile" type="mov">
<child_entries>
<asset id="21" path="//my_computer/test.mp3" name="001-2323" type="mp3"></asset>
<asset id="23" path="//my_computer/test.mp4" name="RequiredFileName" type="mp4"></asset>
<child_entries>
</assets>
樣品.xslt
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Path>
<xsl:for-each select="assets"/>
<xsl:if test="/asset/child_entries/asset/@type = mp4">
<xsl:value-of select="child_entries/asset/@name"/>
</xsl:if>
</Path>
</xsl:template>
謝謝你的閱讀扔它。
想提一提的是,@lwburk解決方案是更好的,只是想提供一個解決方案,更接近於「爲你的代碼工作」。祝你好運! –
謝謝,循環解決了這個問題 – Omer