下面是我的 XML 代码 -
<Para>
<Desc>....</Desc>
<References>
<BookRef>
<BookName>ABC of HTML</BookName>
<Chapter>1</Chapter>
<BookName>HTML : The Complete Reference</BookName>
<Chapter>1</Chapter>
</BookRef>
</References>
</Para>
<Para>
<Desc>....</Desc>
<References>
<BookRef>
<BookName>ABC of XML</BookName>
<Chapter>2</Chapter>
<BookName>XML : The Complete Reference</BookName>
<Chapter>10</Chapter><Chapter>11</Chapter>
</BookRef>
</References>
</Para>
我需要使用 . 以表格格式显示以上内容HTML Table Tag
。所以它应该看起来像 -
Description of Paragraph (the text between the Desc tags)
**Book Name** **Chapters**
ABC of HTML 1
HTML: The Complete Reference 1
Description of Paragraph (the text between the Desc tags)
**Book Name** **Chapters**
ABC of XML 2
HTML: The Complete Reference 10, 11
读者可以直接跳到上述章节,我已经创建了超链接。下面是 XSLT 代码 -
<xsl:template match="References">
<xsl:if test="CaseRef != ''"><br/>
<table border="1" width="100%">
<tr>
<td width="75%">Book Name</td>
<td align="right">Chapters</td>
</tr>
<xsl:for-each select="BookName">
<tr>
<td valign="top">
<xsl:value-of select="."/>
</td>
<td align="right" valign="bottom">
<xsl:for-each select="following::Chapter">
<a id="lnk">
<!-- This code will create a hyperlink to jump directly on the said chapter-->
<xsl:attribute name="href">
<xsl:value-of select="concat(concat('#',.),./@L)"/>
</xsl:attribute>
<xsl:value-of select="."/><xsl:text> </xsl:text>
</a>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:if>
</xsl:template>
我缺少一些东西(可能更多)来获得所需的输出!