XSL如何使用XSL爲id中的每個元素生成唯一的id屬性,其中id必須是數字? 下面的XLS工作除了生成的ID是字母數字,我需要數字?XSL numeric generate-id()
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl='urn:schemas-microsoft-com:xslt' exclude-result-prefixes='msxsl'>
<xsl:output method='xml' indent='yes'/>
<xsl:template match='*'>
<xsl:copy>
<xsl:attribute name='ElementID'>
<xsl:value-of select='generate-id()'/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
謝謝。
它必須是XSLT 1.0嗎?你能更新到2.0嗎? – topskip 2010-04-21 17:55:06
XSLT 2.0可以。 – gregn 2010-04-21 18:03:29
好問題(+1)。查看我的答案以獲得更高效,更簡單的解決方案。 :) – 2010-04-22 13:18:38