gpt4 book ai didi

html - 使用 XSLT 设置内联文本样式和嵌套标签

转载 作者:行者123 更新时间:2023-11-28 08:59:28 24 4
gpt4 key购买 nike

我有一个看起来像这样的 XML 结构。

<root>

<outer-tag>
Some Text
<inner-tag> Some more text </inner-tag>
finally some more text
</outer-tag>

<outer-tag>
....
</outer-tag>

...
</root>

对于上述结构,XSLT 会是什么样子?

我正在做这样的事情,我知道这是错误的。

<xsl:for-each select="outer-tag">
<xsl:value-of select="."/>
<b><xsl:value-of select="inner-tag"/></b>
</xsl:for-each>

这个 XSLT 的输出看起来像

Some text Some more text finally some more text <b>Some more text</b>

我的实际输出应该是

Some text <b>Some more text</b> finally some more text 

预先感谢您的帮助。

最佳答案

将推送式处理与模板匹配和应用模板结合使用,例如

<xsl:template match="inner-tag">
<b>
<xsl:apply-templates/>
</b>
</xsl:template>

然后默认模板将负责确保处理过程保持不变,或者您可以编写自己的模板,例如

<xsl:template match="outer-tag">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>

关于html - 使用 XSLT 设置内联文本样式和嵌套标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26991398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com