Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/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
Json 需要删除<;文本xmlns=";http://ws.apache.org/commons/ns/payload"&燃气轮机;从使用中的输出<;xsl:output-method=";文本>;xslt中介_Json_Xslt_Wso2_Wso2 Am_Xsl Output - Fatal编程技术网

Json 需要删除<;文本xmlns=";http://ws.apache.org/commons/ns/payload"&燃气轮机;从使用中的输出<;xsl:output-method=";文本>;xslt中介

Json 需要删除<;文本xmlns=";http://ws.apache.org/commons/ns/payload"&燃气轮机;从使用中的输出<;xsl:output-method=";文本>;xslt中介,json,xslt,wso2,wso2-am,xsl-output,Json,Xslt,Wso2,Wso2 Am,Xsl Output,我在wso2 studio developer中使用xslt中介。我在wso2 carbon->conf中添加以下代码作为本地实体(添加资源),并在我的xslt中介中使用它作为“键”。我有json格式的输出对象列表。因为我甚至需要一个对象的列表,所以我使用这个中介而不是foreach中介 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet exclude-result-prefixes="xs" version="2.0

我在wso2 studio developer中使用xslt中介。我在wso2 carbon->conf中添加以下代码作为本地实体(添加资源),并在我的xslt中介中使用它作为“键”。我有json格式的输出对象列表。因为我甚至需要一个对象的列表,所以我使用这个中介而不是foreach中介

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="xs" version="2.0" xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:a="http://schemas.datacontract.org/2004/07/Asa.Mbdp.Platform.Publish.Tmc.Head.Proxy" 
        xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:t="http://tempuri.org/">   
<xsl:output encoding="UTF-8" indent="yes" media-type="application/json"  method="text"/> 
<xsl:strip-space elements="*"/>
    <xsl:template match="/">
        {
        "Response":{
            "LivePrices":[
            <xsl:for-each select="s:Envelope/s:Body/t:LivePricesResponse/t:LivePricesResult/a:Close">
            {
            "Last":"<xsl:value-of select="a:Last"/>" , 
            "Price":"<xsl:value-of select="a:Price"/>",
            "Quantity":"<xsl:value-of select="a:Quantity"/>",
            "Since":"<xsl:value-of select="a:Since"/>"
            }
            <xsl:if test="position()!=last()">,</xsl:if>
            </xsl:for-each>             
            ]
        }
    }
    </xsl:template>
</xsl:stylesheet>

使用XSLT后,将下面的代码放入序列中

 <property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
    <payloadFactory media-type="json">
        <format>$1</format>
        <args>
            <arg evaluator="xml" expression="$body//*" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args>
    </payloadFactory>
<respond/>

$1
这将为您提供预期的输出

{
        "Response":{
            "LivePrices":[

            {
            "Last":"1880" , 
            "Price":"1851",
            "Quantity":"0",
            "Since":"2018-07-26T00:00:00"
            }

            ]
        }
    }
 <property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
    <payloadFactory media-type="json">
        <format>$1</format>
        <args>
            <arg evaluator="xml" expression="$body//*" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args>
    </payloadFactory>
<respond/>