如何使用 XSLT 从 XML 文件中的特定标签创建 linkTag
我想更改以下 XML 中的具体标签。标签
应转换为
和标签
应转换为
。
<root>
<directCompNotes>
<paragraph>Go to:</paragraph>
<bullet-list>
<item>
<paragraph>
<linkSource>
Booth
</linkSource>
</paragraph>
</item>
<item>
<paragraph>
WithoutLinkSource
</paragraph>
</item>
</bullet-list>
</directCompNotes>
<directComp>
<paragraph>
<linkDestination>
Explainition
</linkDestination>
</paragraph>
</directComp>
</root>
这就是我试图做的:
<xsl:template match="root">
<xsl:for-each select="directCompNotes/bullet-list/item/paragraph/linkSource">
<fo:basic-link internal-destination="boothId">
<xsl:value-of select="."/>
</fo:basic-link>
</xsl:for-each>
</xsl:template>
目标是我应该能够创建从“Booth”到“Explanition”的链接。所有 linkSource 和 linkDestination 都在已定义的 XML 文件中。
有人可以帮我吗?
(抱歉,我的英语不是很好,但我希望我能够很好地解释这个问题)。
I want to change the specifics Tags in following XML. The tags <linkSource>
should be convert to <fo:basic-link internal-destination="boothId">
and the tag <linkDestination>
should be convertet to <fo:block id="boothId">
.
<root>
<directCompNotes>
<paragraph>Go to:</paragraph>
<bullet-list>
<item>
<paragraph>
<linkSource>
Booth
</linkSource>
</paragraph>
</item>
<item>
<paragraph>
WithoutLinkSource
</paragraph>
</item>
</bullet-list>
</directCompNotes>
<directComp>
<paragraph>
<linkDestination>
Explainition
</linkDestination>
</paragraph>
</directComp>
</root>
That is what I tried to do:
<xsl:template match="root">
<xsl:for-each select="directCompNotes/bullet-list/item/paragraph/linkSource">
<fo:basic-link internal-destination="boothId">
<xsl:value-of select="."/>
</fo:basic-link>
</xsl:for-each>
</xsl:template>
The goal is that I should be able to create a link from "Booth" to "Explanition". All of the linkSource and linkDestinition are in the XML file already defined.
Can anyone help me please?
(Sorry, My English is not very well, but I hope I was able to explain the question well).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试以下 XSLT。
输入 XML
XSLT
输出 XML
Please try the following XSLT.
Input XML
XSLT
Output XML