[DEV] [PET] Removing element using script mediator

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[DEV] [PET] Removing element using script mediator

kalyani
Hi All,

I'm working on Google contacts connector. For create Contact method we need to set the request format as,
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/contact/2008#contact"/>
<atom:content type="text">$1</atom:content>
<gd:name>
<gd:givenName>$2</gd:givenName>
<gd:familyName>$3</gd:familyName>
<gd:fullName>$4</gd:fullName>
</gd:name>
<gd:email rel="http://schemas.google.com/g/2005#work"
primary="true"
address="$ctx:workEmail" displayName="E. Bennet"/>
<gd:email rel="http://schemas.google.com/g/2005#home"
address="$ctx:homeEmail"/>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work"
primary="true">$7</gd:phoneNumber>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home">$8</gd:phoneNumber>
<gd:structuredPostalAddress
rel="http://schemas.google.com/g/2005#work"
primary="true">
<gd:city>$9</gd:city>
<gd:street>$10</gd:street>
<gd:region>$11</gd:region>
<gd:postcode>$12</gd:postcode>
<gd:country>$13</gd:country>
<gd:formattedAddress>$14</gd:formattedAddress>
</gd:structuredPostalAddress>
</atom:entry>
Here some parameters are optional. If it is optional parameter and value is not set, it's not needed in the request. for example,
givenName is optional and it's null, then request should be as,
<gd:name>
<gd:familyName>$3</gd:familyName>
<gd:fullName>$4</gd:fullName>
</gd:name>
Here each element has name-space. How can I remove this kind of element from payload?
Any guide on this?

--
Kalyani Yogeswaranathan
Associate software engineer
WSO2 Inc.

Mobile: 0776390284

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [DEV] [PET] Removing element using script mediator

malakasilva
Hi Kalyani,

You can use script mediator to do this [1].

However best I think is to add the elements as needed rather than adding them and deleting them.

You can try the enrich mediator or script mediator again to add xml tags. [2]


On Fri, Mar 11, 2016 at 1:28 PM, Kalyani Yogeswaranathan <[hidden email]> wrote:
Hi All,

I'm working on Google contacts connector. For create Contact method we need to set the request format as,
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/contact/2008#contact"/>
<atom:content type="text">$1</atom:content>
<gd:name>
<gd:givenName>$2</gd:givenName>
<gd:familyName>$3</gd:familyName>
<gd:fullName>$4</gd:fullName>
</gd:name>
<gd:email rel="http://schemas.google.com/g/2005#work"
primary="true"
address="$ctx:workEmail" displayName="E. Bennet"/>
<gd:email rel="http://schemas.google.com/g/2005#home"
address="$ctx:homeEmail"/>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work"
primary="true">$7</gd:phoneNumber>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home">$8</gd:phoneNumber>
<gd:structuredPostalAddress
rel="http://schemas.google.com/g/2005#work"
primary="true">
<gd:city>$9</gd:city>
<gd:street>$10</gd:street>
<gd:region>$11</gd:region>
<gd:postcode>$12</gd:postcode>
<gd:country>$13</gd:country>
<gd:formattedAddress>$14</gd:formattedAddress>
</gd:structuredPostalAddress>
</atom:entry>
Here some parameters are optional. If it is optional parameter and value is not set, it's not needed in the request. for example,
givenName is optional and it's null, then request should be as,
<gd:name>
<gd:familyName>$3</gd:familyName>
<gd:fullName>$4</gd:fullName>
</gd:name>
Here each element has name-space. How can I remove this kind of element from payload?
Any guide on this?

--
Kalyani Yogeswaranathan
Associate software engineer
WSO2 Inc.

Mobile: <a href="tel:0776390284" value="+94776390284" target="_blank">0776390284

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--

Best Regards,

Malaka Silva
Senior Tech Lead
M: +94 777 219 791
Fax :94 11 2145300 
Skype : malaka.sampath.silva
LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77

WSO2, Inc. 
lean . enterprise . middleware 
http://www.wso2.com/

Save a tree -Conserve nature & Save the world for your future. Print this email only if it is absolutely necessary.

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [DEV] [PET] Removing element using script mediator

kalyani
Hi Malaka,

I have done as you mentioned add the elements as needed.

Thanks for the reply.

On Fri, Mar 11, 2016 at 9:32 PM, Malaka Silva <[hidden email]> wrote:
Hi Kalyani,

You can use script mediator to do this [1].

However best I think is to add the elements as needed rather than adding them and deleting them.

You can try the enrich mediator or script mediator again to add xml tags. [2]


On Fri, Mar 11, 2016 at 1:28 PM, Kalyani Yogeswaranathan <[hidden email]> wrote:
Hi All,

I'm working on Google contacts connector. For create Contact method we need to set the request format as,
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/contact/2008#contact"/>
<atom:content type="text">$1</atom:content>
<gd:name>
<gd:givenName>$2</gd:givenName>
<gd:familyName>$3</gd:familyName>
<gd:fullName>$4</gd:fullName>
</gd:name>
<gd:email rel="http://schemas.google.com/g/2005#work"
primary="true"
address="$ctx:workEmail" displayName="E. Bennet"/>
<gd:email rel="http://schemas.google.com/g/2005#home"
address="$ctx:homeEmail"/>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work"
primary="true">$7</gd:phoneNumber>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home">$8</gd:phoneNumber>
<gd:structuredPostalAddress
rel="http://schemas.google.com/g/2005#work"
primary="true">
<gd:city>$9</gd:city>
<gd:street>$10</gd:street>
<gd:region>$11</gd:region>
<gd:postcode>$12</gd:postcode>
<gd:country>$13</gd:country>
<gd:formattedAddress>$14</gd:formattedAddress>
</gd:structuredPostalAddress>
</atom:entry>
Here some parameters are optional. If it is optional parameter and value is not set, it's not needed in the request. for example,
givenName is optional and it's null, then request should be as,
<gd:name>
<gd:familyName>$3</gd:familyName>
<gd:fullName>$4</gd:fullName>
</gd:name>
Here each element has name-space. How can I remove this kind of element from payload?
Any guide on this?

--
Kalyani Yogeswaranathan
Associate software engineer
WSO2 Inc.

Mobile: <a href="tel:0776390284" value="+94776390284" target="_blank">0776390284

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--

Best Regards,

Malaka Silva
Senior Tech Lead
M: <a href="tel:%2B94%20777%20219%20791" value="+94777219791" target="_blank">+94 777 219 791
Fax :94 11 2145300 
Skype : malaka.sampath.silva
LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77

WSO2, Inc. 
lean . enterprise . middleware 
http://www.wso2.com/

Save a tree -Conserve nature & Save the world for your future. Print this email only if it is absolutely necessary.



--
Kalyani Yogeswaranathan
Associate software engineer
WSO2 Inc.

Mobile: 0776390284

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev