我有下面的XML:子串並在XSLT分組問題2.0
<InterSection criteria="Microsoft-ASP">value</Intersection>
<InterSection criteria="Microsoft-MVC">value</Intersection>
<InterSection criteria="HP-MVC">value</Intersection>
我需要在我的HTML頁面的頂部創建TOC,所以我需要按標準(前第一部分「 - 」) 。
我需要一個像
- 不同的值微軟
- HP
我的XSLT有下面的代碼
<a>
<xsl:attribute name="href">
<xsl:text>#trigger</xsl:text>
<xsl:value-of select="position()"/>
</xsl:attribute>
<xsl:for-each-group select="." group-by="substring-before(@Criteria, ' - ')">
<xsl:value-of select="substring-before(@Criteria, ' - ')"/>
<xsl:text>
</xsl:text>
</xsl:for-each-group>
</a>
但不知何故,我得到
- 微軟
- 微軟
- HP
,而不是 1.微軟 2. HP
我有以下寫在我的XSLT
<xsl:template match="InterSection" mode="TOC">
<li>
<a>
<xsl:attribute name="href">
<xsl:text>#trigger</xsl:text>
<xsl:value-of select="position()"/>
</xsl:attribute>
<xsl:for-each-group select="." group-by="substring-before(@Criteria, ' - ')">
<xsl:value-of select="current-grouping-key()"/>
<xsl:for-each select="current-group()"/>
</xsl:for-each-group>
</a>
</li>
你的工作是一團糟:案件不保留(例如, 'InterSection'用'Intersection'關閉),你在模板中使用'Criteria',而在輸入時你有'criteria',你用子空間(' - ')來取。連字符(' - ')之間沒有空格。 – 2011-05-24 20:16:07
我終於嘗試總結了所有我將解決的問題,以使其工作。 – 2011-05-25 05:13:52