0
我有一些XML,看起來像這樣:如何在XSL中選擇單個屬性值?
<interp type="flowers color">Here is something concerning flowers and color.</interp>
而且我試圖把它改造成這樣的:
<td class="interp">
<span class="tag">flowers</span>
<span class="tab">color</span>
Here is something concerning flowers and color.
</td>
所以這是我一直想的XSL:
<xsl:template match="interp">
<td class="interp">
<xsl:apply-templates select="@type | node()"/>
</td>
</xsl:template>
<xsl:template match="@type">
<xsl:for-each select=".">
<span class="tag">
<xsl:value-of select="."/>
</span>
</xsl:for-each>
</xsl:template>
但我得到的是更多這樣的:
<span class="tag">flowers color</span>
Here is something concerning flowers and color.
我做錯了什麼,以及如何獲得這些屬性值分開?
我剛剛使用Firefox,當我嘗試使用tokenize函數時,它說「XSLT轉換期間出錯:調用了未知的XPath擴展函數。」 – Jono
好吧,我說'tokenize'方法與XSLT 2.0處理器協同工作,不幸的是,瀏覽器迫使您使用1999年以來的XSLT 1.0。請參閱http://stackoverflow.com/questions/33838519/turn-xml-attribute-with-2 -or-more-values-into-svg-xy-coordinates-using-xsl/33843236#33843236關於如何使用命名模板標記XSLT 1.0中的屬性值的示例。 –