Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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版本=&;引用;1.0及;引用;编码=&;引用;utf-8&;引用&;燃气轮机&引用;内部节点XML编码的XSLT1.0_Xml_Xslt_Escaping_Xslt 1.0_Dtd - Fatal编程技术网

如何测试“是否”&;书信电报;?xml版本=&;引用;1.0及;引用;编码=&;引用;utf-8&;引用&;燃气轮机&引用;内部节点XML编码的XSLT1.0

如何测试“是否”&;书信电报;?xml版本=&;引用;1.0及;引用;编码=&;引用;utf-8&;引用&;燃气轮机&引用;内部节点XML编码的XSLT1.0,xml,xslt,escaping,xslt-1.0,dtd,Xml,Xslt,Escaping,Xslt 1.0,Dtd,我有一个要求,我试图从节点提取转义XML字符我所面临的挑战是如何在转义XML消息中声明XML 这是输入(XML声明) 存货实际价值 发展 发送文件 943fe0e5-2f88-48ce-ae3c-f7124ee498fd e9b3af1d-70fd-43c0-b467-df21fd903672 ?xml version=“1.0”encoding=“utf-8”? testsomething信息/测试 test1someotherinfo/test1 ; 挑战:如果代码具有XML声明,则代码

我有一个要求,我试图从节点提取转义XML字符
我所面临的挑战是如何在转义XML消息中声明XML

这是输入(XML声明)


存货实际价值
发展
发送文件
943fe0e5-2f88-48ce-ae3c-f7124ee498fd
e9b3af1d-70fd-43c0-b467-df21fd903672
?xml version=“1.0”encoding=“utf-8”?
testsomething信息/测试
test1someotherinfo/test1
;
挑战:如果代码具有XML声明,则代码可以正常工作,但是可能存在不具有XML声明的情况

示例:没有XML声明

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns2:processInboundMessage xmlns:ns2="http://integration.nexuse2e.org/BackendDeliveryInterface/">
            <choreographyId>InventoryActualUsage</choreographyId>
            <businessPartnerId>Development</businessPartnerId>
            <actionId>SendFile</actionId>
            <conversationId>943fe0e5-2f88-48ce-ae3c-f7124ee498fd</conversationId>
            <messageId>e9b3af1d-70fd-43c0-b467-df21fd903672</messageId>
            <payload>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;test&gt;somethinginformation&lt;/test&gt;
&lt;test1&gt;someotherinfo&lt;/test1&gt;
    ;</payload>
        </ns2:processInboundMessage>
    </soap:Body>
</soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns2:processInboundMessage xmlns:ns2="http://integration.nexuse2e.org/BackendDeliveryInterface/">
            <choreographyId>InventoryActualUsage</choreographyId>
            <businessPartnerId>Development</businessPartnerId>
            <actionId>SendFile</actionId>
            <conversationId>943fe0e5-2f88-48ce-ae3c-f7124ee498fd</conversationId>
            <messageId>e9b3af1d-70fd-43c0-b467-df21fd903672</messageId>
            <payload>
&lt;test&gt;somethinginformation&lt;/test&gt;
&lt;test1&gt;someotherinfo&lt;/test1&gt;
    ;</payload>
        </ns2:processInboundMessage>
    </soap:Body>
</soap:Envelope>

存货实际价值
发展
发送文件
943fe0e5-2f88-48ce-ae3c-f7124ee498fd
e9b3af1d-70fd-43c0-b467-df21fd903672
testsomething信息/测试
test1someotherinfo/test1
;
代码:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:date="http://exslt.org/dates-and-times" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp" exclude-result-prefixes=" date">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
    <xsl:template match="node()|@*">
        <xsl:apply-templates select="node()|@*"/>
    </xsl:template>
    <xsl:template match="payload">
        <xsl:variable name="xmlencode" select="'&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;'"/>
        <xsl:variable name="message">
            <xsl:choose>
                <xsl:when test="contains($xmlencode,'?&gt;')">
                    <xsl:value-of select="substring-after(text(),'?&gt;')"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="."/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
            <soapenv:Header/>
            <soapenv:Body>
                <xsl:value-of select="$message" disable-output-escaping="yes"/>
            </soapenv:Body>
        </soap:Envelope>
    </xsl:template>
</xsl:stylesheet>

我在第二种情况下遇到了问题,如果XML声明不可用,我什么也得不到

获得如下输出:

<soap:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body/>
</soap:Envelope>

预期产出

<soap:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
<test>somethinginformation</test>
<test1>someotherinfo</test1>
    </soapenv:Body>
</soap:Envelope>

一些信息
其他信息