使用XSLT设置内嵌文本以及嵌套标记 [英] Style inline text along with nested tags with XSLT
本文介绍了使用XSLT设置内嵌文本以及嵌套标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个看起来像这样的XML结构。
I have an XML structure that looks something like this.
<root>
<outer-tag>
Some Text
<inner-tag> Some more text </inner-tag>
finally some more text
</outer-tag>
<outer-tag>
....
</outer-tag>
...
</root>
XSLT对于上述结构如何?
How would the XSLT look like for the above structure?
我正在做这样的事情,我知道这是错误的。
I am doing something like this, which I know is wrong.
<xsl:for-each select="outer-tag">
<xsl:value-of select="."/>
<b><xsl:value-of select="inner-tag"/></b>
</xsl:for-each>
此XSLT的输出看起来像
And the output for this XSLT looks like
一些文字一些更多文字最后一些更多文字< b>一些更多文字< / b>
我的实际产出应该是
My actual output should be
Some text <b>Some more text</b> finally some more text
预先感谢您的帮助。
推荐答案
在模板匹配和应用模板中使用推式处理例如
Use push style processing with template matching and apply-templates e.g.
<xsl:template match="inner-tag">
<b>
<xsl:apply-templates/>
</b>
</xsl:template>
那么默认的模板会负责确保处理过程保持不变,或者您可以编写自己的模板用例如
then the default templates would take care of making sure the processing is kept up or you can write your own doing that with e.g.
<xsl:template match="outer-tag">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
这篇关于使用XSLT设置内嵌文本以及嵌套标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文