且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

XSLT - 如何将带有递归元素的 xml 解析为 Eclipse toc.xml?

更新时间:2023-11-04 11:03:04

我认为以下内容可以满足您的需求:

I think the following does what you want:

<xsl:template match="BODY">
    <toc label="Sample Table of Contents">
        <xsl:apply-templates select="UL/LI/OBJECT"/>
  </toc>
</xsl:template>

<xsl:template match="OBJECT">
  <topic label="{param[@name='Name']/@value}" href="{param[@name='Local']/@value}">
    <xsl:apply-templates select="following-sibling::UL/LI/OBJECT"/>
  </topic>
</xsl:template>