在XSLT转换后保留注释 [英] retain comments post XSLT transform

查看:198
本文介绍了在XSLT转换后保留注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要将XML文件中的注释保留到输出XML中。应用XSLT后。





有没有人知道如何/如果这是可能的?
谢谢!

解决方案

在您的XSL中,您可以引用源XML中的注释,类似于其他元素,例如: / p>

 < xsl:template match =comment()> 
< xsl:value-of select =。/>
< / xsl:template>

如果它应该作为注释出现在转换后的XML中,您可以执行以下操作:

 < xsl:template match =comment()> 
< xsl:comment>
< xsl:value-of select =。/>
< / xsl:comment>
< / xsl:template>


This seems like an easy one, but one that I haven't come across before.

I need to retain the comments in an XML file to the output XML after applying an XSLT.

Does anyone know how/if this is possible? Thanks!

解决方案

In your XSL you can reference comments in your source XML similar to other elements, e.g.:

<xsl:template match="comment()">
    <xsl:value-of select="."/>
</xsl:template>

If it should appear in your transformed XML as comment as well you can do the following:

<xsl:template match="comment()">
    <xsl:comment>
        <xsl:value-of select="."/>
    </xsl:comment>
</xsl:template>

这篇关于在XSLT转换后保留注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆