Hi,

Following script will do the job:

<script language="js">
var fullContent =  mc.getPayloadXML();
for(var index in  fullContent..*::advancedImageSearchVO.children()){


    var b = fullContent..*::advancedImageSearchVO.children()[index];




         if(b.toString() ==''){
     delete fullContent..*::advancedImageSearchVO.children()[index];
   }

     }
   mc.setPayloadXML(fullContent);

</script>

Thanks!


On Wed, Feb 4, 2015 at 2:50 PM, Awanthika Senarath <[email protected]>
wrote:

>
> Hi,
>
> in trying to do $subject, i am using the script mediator as folows
>
> * <script language="js">*
>
> *var fullContent =  mc.getPayloadXML();  *
> *var entity = mc.getPayloadXML()..*::entity;*
>
> *if (entity==null){*
> *      fullContent.removeChild(entity);*
> *   } *
>
> *mc.setPayloadXML(fullContent);*
>
> *</script>*
>
>
> but my output always contains the empty tag <entity>
>
> sample xml output received
>
> Envelope:
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
> http://www.w3.org/2003/05/soap-envelope";>
> <soapenv:Body>
> <ejb:getAdvancedDocumentReferenceList xmlns:ejb="http://ejb.image.pfpc.com";
> xmlns:vo="http://vo.image.pfpc.com";>
> <ejb:provider>myProvidor</ejb:provider>
>
> <ejb:advancedImageSearchVO>
>
> <vo:departmentID>myID</vo:departmentID>
> <vo:entity></vo:entity>         <--------- empty xml tag with no content
>
> </ejb:advancedImageSearchVO>
>
> </ejb:getAdvancedDocumentReferenceList>
> </soapenv:Body>
> </soapenv:Envelope>
>
>
> where as the expected output shoud be
>
>
> Envelope:
> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
> http://www.w3.org/2003/05/soap-envelope";>
> <soapenv:Body>
> <ejb:getAdvancedDocumentReferenceList xmlns:ejb="http://ejb.image.pfpc.com";
> xmlns:vo="http://vo.image.pfpc.com";>
> <ejb:provider>myProvidor</ejb:provider>
>
> <ejb:advancedImageSearchVO>
>
> <vo:departmentID>myID</vo:departmentID>
>
>
> </ejb:advancedImageSearchVO>
>
> </ejb:getAdvancedDocumentReferenceList>
> </soapenv:Body>
> </soapenv:Envelope>
>
>
>
> can someone point out what I am doing wrong?
>
>
> --
> Awanthika Senarath
> Software Engineer, WSO2 Inc.
> Mobile: +94717681791
>
>
>


-- 
Buddhima Wijeweera
Software Engineer; WSO2 Inc.; http://wso2.com ,

Mobile: +94 71 427 9966
Email: [email protected]
Blog:   https://buddhimawijeweera.wordpress.com
GitHub Profile: https://github.com/Buddhima
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to