Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml XSLT转换后保留注释_Xml_Xslt_Comments - Fatal编程技术网

Xml XSLT转换后保留注释

Xml XSLT转换后保留注释,xml,xslt,comments,Xml,Xslt,Comments,这看起来很简单,但我以前从未见过 在应用XSLT之后,我需要将XML文件中的注释保留到输出XML中 有人知道如何/如果可能吗? 谢谢 在XSL中,您可以引用源XML中与其他元素类似的注释,例如: <xsl:template match="comment()"> <xsl:value-of select="."/> </xsl:template> 如果它也作为注释出现在转换后的XML中,则可以执行以下操作: <xsl:template mat

这看起来很简单,但我以前从未见过

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

有人知道如何/如果可能吗?
谢谢

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

<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>


谢谢Matthias。我在XSLT中有这个,但没有得到任何输出。我发现XSLT已经有一个模板match=“comment()”,并设置为禁止它们。标准标识转换有一个模板匹配
node()|@*
。注释是
node()
匹配的内容之一。