retain comments post XSLT transform

て烟熏妆下的殇ゞ 提交于 2019-12-11 16:38:20

问题


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!


回答1:


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>


来源:https://stackoverflow.com/questions/16407636/retain-comments-post-xslt-transform

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!