32

こんにちは、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> 

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

電流出力

   <?xml version="1.0" encoding="utf-16"?>
    <Entity>RIM_BPS</Entity>

期待される出力

    <Entity>RIM_BPS</Entity>
4

4 に答える 4

44

タグにomit-xml-declaration="yes"属性を追加してみてください。xsl:output

次に、次のようになります。

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
于 2013-02-10T18:00:43.873 に答える
15

これをxsltに入れます

<xsl:output method="xml" omit-xml-declaration="yes"/>

また

極端なプッシュで

<xsl:output method="text" />

症状を解決する必要があります...

最後のものは、プロセッサによっては重大な結果をもたらす可能性があります。

于 2013-02-10T18:01:13.180 に答える
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>
于 2014-06-05T06:50:38.120 に答える
2

この完全な変換:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:JT="http://jerseytelecom.com/" exclude-result-prefixes="soap JT">
<xsl:output omit-xml-declaration="yes" indent="yes"
     encoding="utf-8"/>
 <xsl:template match="/">
  <Entity>
   <xsl:value-of select=
   "soap:Envelope/soap:Body/JT:CreateResponse
              /JT:CreateResult/JT:ISD_XMLGateway/JT:Entity"/>
  </Entity>
 </xsl:template>
</xsl:stylesheet>

提供された 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>

必要な正しい結果が生成されます。

<Entity>RIM_BPS</Entity>
于 2013-02-11T01:07:19.970 に答える