sha*_*sha 29 xml xslt xpath xslt-1.0
您好我通过将xsl应用于xml输入来生成xml.我需要没有这部分的输出"<?xml version="1.0" encoding="utf-16"?>"
输入 - XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CreateResponse xmlns="http://jerseytelecom.com/">
<CreateResult>
<ISD_XMLGateway>
<Entity>RIM_BPS</Entity>
</ISD_XMLGateway>
</CreateResult>
</CreateResponse>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
我的xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:JT="http://jerseytelecom.com/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="JT">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:element name="Entity">
<xsl:value-of select="soap:Envelope/soap:Body/JT:CreateResponse/JT:CreateResult/JT:ISD_XMLGateway/JT:Entity"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
电流输出
<?xml version="1.0" encoding="utf-16"?>
<Entity>RIM_BPS</Entity>
Run Code Online (Sandbox Code Playgroud)
预期产出
<Entity>RIM_BPS</Entity>
Run Code Online (Sandbox Code Playgroud)
Chr*_*isC 40
尝试将该omit-xml-declaration="yes"属性添加到您的xsl:output代码中.
它应该像这样读:
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
Run Code Online (Sandbox Code Playgroud)
Ton*_*son 12
把它放在你的xslt中
<xsl:output method="xml" omit-xml-declaration="yes"/>
Run Code Online (Sandbox Code Playgroud)
要么
极度推动
<xsl:output method="text" />
Run Code Online (Sandbox Code Playgroud)
应该解决症状......
最后一个可能会产生重大影响,但取决于处理器.
小智 5
使用此 XSLT 从使用 XSLT 的 xml 文档中删除 encoding=“UTF-8”。在 Cdaata 部分中,您可以根据需要添加编码。干杯:)
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><![CDATA[<?xml version="1.0"?>]]></xsl:text>
<xsl:copy-of select="node()"/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)