我可以向 XSLT 输出添加 XML 声明吗? [英] Can I add an XML declaration to an XSLT output?
本文介绍了我可以向 XSLT 输出添加 XML 声明吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我当前的 XML 输出:
Here is my current XML output:
<EmployeeImport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Employee>
<EmployeeNumber>123</EmployeeNumber>
<FirstName>Jose</FirstName>
</Employee>
</EmployeeImport>
等等.我想要的输出如下:
and so on. What I would like to have my output is the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<EmployeeImport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Employee>
<EmployeeNumber>123</EmployeeNumber>
<FirstName>Jose</FirstName>
</Employee>
</EmployeeImport>
我希望能够将第一行添加到我的输出中.在我的 XSLT 中,我尝试了 <
I would like to be able to add the first line to my output. In my XSLT, I have tried <
打印<"但它被解释为 <
.我也试过
,但遇到了同样的问题.有没有办法将此声明行添加到我的 XSLT 中?
to print "<" but it is interpreted just as <
. I have also tried <xsl:text>
, but ran into the same issue. Is there a way to add this declaratory line to my XSLT?
推荐答案
只需使用 xsl:输出.
示例...
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output version="1.0" encoding="UTF-8" standalone="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
这篇关于我可以向 XSLT 输出添加 XML 声明吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文