在使用 <xsl:output method="text> xslt 调解器时需要从输出中删除 <text xmlns="http://ws.apache.org/commons/ns/payload">

need to remove <text xmlns="http://ws.apache.org/commons/ns/payload"> from output in using <xsl:output method="text> xslt mediator

我在 wso2 studio 中使用 xslt mediator developer.I 在 wso2 carbon->conf 中添加以下代码作为本地实体(添加资源)并在我的 xslt mediator 中使用它作为 "key"。我有 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>

我的回复以我不想在回复中出现的文本标签开头。我怎样才能删除这个文本标签。

<text xmlns="http://ws.apache.org/commons/ns/payload">
        {
        "Response":{
            "LivePrices":[

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

            ]
        }
    }
    </text>

我想要这个回复:

{
        "Response":{
            "LivePrices":[

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

            ]
        }
    }

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

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

这应该会给你预期的输出