Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
Xslt 如何删除响应部分中的复杂元素_Xslt_Xpath_Wso2_Xquery - Fatal编程技术网

Xslt 如何删除响应部分中的复杂元素

Xslt 如何删除响应部分中的复杂元素,xslt,xpath,wso2,xquery,Xslt,Xpath,Wso2,Xquery,我正在使用wso2esb 4.8.1, 我希望使用xquery或xpath删除响应数据中的复杂元素 <soapenv:Body> <open:reponce xmlns:open="http://www.openuri.org/"> <env:hjEnvelope xmlns:env="http://hj.mn.mw/Envelope"> <env:UserId>as</env:User

我正在使用wso2esb 4.8.1, 我希望使用xquery或xpath删除响应数据中的复杂元素

 <soapenv:Body>
      <open:reponce xmlns:open="http://www.openuri.org/">
         <env:hjEnvelope xmlns:env="http://hj.mn.mw/Envelope">
            <env:UserId>as</env:UserId>
            <env:Sender>as</env:Sender>
            <env:MessageId>22195544</env:MessageId>
            <env:CorrelationId>1</env:CorrelationId>
            <env:GenTimeStamp>1</env:GenTimeStamp>
            <env:SentTimeStamp>1</env:SentTimeStamp>
            <env:Payload>
               <MOP xmlns="http://hj.mn.mw/MOP" xmlns:ns2="http://www.openuri.org/">
                  <Response>
                     <Result_OutputData>
                        <resultCode>0</resultCode>
                        <reference_ID>90</reference_ID>
                     </Result_OutputData>
                     <Response_OutputData>
                        <SystemName>google</SystemName>
                        <InterfaceName>nip</InterfaceName>
                        <ResultCode>0</ResultCode>
                        <ResultMessage/>
                        <ReferenceID>90</ReferenceID>
                     </Response_OutputData>
                  </Response>
               </MOP>
            </env:Payload>
         </env:hjEnvelope>
      </open:reponce>
   </soapenv:Body>
</soapenv:Envelope>
但它不起作用。即使我也试过使用我的xquery,它也不起作用

Xquery更改是

<x xmlns="http://ws.apache.org/ns/synapse">
declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope";
declare namespace soap="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace open="http://www.openuri.org/";
declare namespace env="http://eai.bo.mw/Envelope";
declare variable $Response as document-node() external;
declare variable $hjEnvelope as document-node() external;
element{'open:reponce'}{
element{'env:hjEnvelope'}{$hjEnvelope//env:hjEnvelope/*[not(local-name()='Payload')],
element{'env:Payload'}{
$Response//soap:Body/*[1]/*[not(local-name()='Response_OutputData')]
    }}
    }

声明命名空间soapenv=”http://schemas.xmlsoap.org/soap/envelope";
声明命名空间soap=”http://schemas.xmlsoap.org/soap/envelope/";
声明命名空间打开=”http://www.openuri.org/";
声明命名空间env=”http://eai.bo.mw/Envelope";
将变量$Response声明为document-node()外部;
将变量$Hjevelope声明为document-node()外部;
元素{'open:responce'}{
元素{'env:hjevelope'}{$hjevelope//env:hjevelope/*[not(local-name()='Payload'),
元素{'env:Payload'}{
$Response//soap:Body/*[1]/*[not(local-name()='Response\u OutputData')]
}}
}

如何删除此响应的复杂元素

您需要执行标识转换,将输入到输出的所有内容都复制到要跳过的元素之外。例如:

xquery version "1.0";

declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope";

declare function local:filter($nodes as node()*, $names as xs:string+) {
    for $n in $nodes
    return
        typeswitch($n)
            case element() return
                if(not(local-name($n) = $names))then
                    element {node-name($n)} {
                        local:filter($n/(@*|child::node()), $names)
                    }
                else()

            default return
                $n
};


local:filter(/soapenv:body, ("Response_OutputData"))

对于上面的查询,我得到了上面的回复,我希望删除复杂的元素
xquery version "1.0";

declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope";

declare function local:filter($nodes as node()*, $names as xs:string+) {
    for $n in $nodes
    return
        typeswitch($n)
            case element() return
                if(not(local-name($n) = $names))then
                    element {node-name($n)} {
                        local:filter($n/(@*|child::node()), $names)
                    }
                else()

            default return
                $n
};


local:filter(/soapenv:body, ("Response_OutputData"))