sax filter escaping xml characters in smooks. how to overcome this issue.

239 views
Skip to first unread message

Rakshitha Shetty

unread,
Jan 25, 2017, 5:20:53 AM1/25/17
to Smooks Users
am using smooks_1.4.0.wso2.jar that comes along with the wso2 esb-4.8.1.

I have this code snippet in my smooks config

<params>
    <param name="stream.filter.type">SAX</param>
</params>

this is escaping xml special characters from my csv payload while converting it into json.

Could you please help me find a work around for this.

I know removing the SAX filter would avoid escaping but i need SAX filter since i have a really huge csv data.

Tom Fennelly

unread,
Jan 25, 2017, 6:01:55 AM1/25/17
to smook...@googlegroups.com
You mean it is leaving xml entities in the generated JSON? If so, that's more of an issue with the JSON generation, I would think. Hmmm ... did you look for help from the wso2 people?

--
You received this message because you are subscribed to the Google Groups "Smooks Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-user+unsubscribe@googlegroups.com.
To post to this group, send email to smook...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-user/a1654d00-af48-456e-a66a-8127d83a584d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rakshitha Shetty

unread,
Jan 25, 2017, 6:27:54 AM1/25/17
to Smooks Users
Tom Fennelly,

Thanks for your response.

No it is escaping the xml entities in the generated JSON.

like i have a payload which says user first name is tina's

the json output gives it as { first_name: tina&amp;s }

this is nothing to do with the JSON generation. 

json generation is fine in places where i am not using a sax filter

I went through few more articles that said SAX filter would escape the xml characters.

below links are for your reference

http://stackoverflow.com/questions/26265389/how-do-i-stop-smooks-from-escaping-ampersand

http://milyn.996300.n3.nabble.com/How-do-I-prevent-smooks-from-escaping-ampersands-td8930.html

and finally  i have not got in touch with wso2 people yet.

Tom Fennelly

unread,
Jan 25, 2017, 6:59:42 AM1/25/17
to smook...@googlegroups.com
That's actually what I mean. The fact that the SAX filter is producing entity references is actually right. If something after that step in the process wants to output that data in a different format (in your case JSON), then it's the responsibility of that something to remove entities or other that are not right for that format. I hope I'm making sense.

So ... you need some way of stripping the entities before they make it into the JSON. I think you need to talk to your wso2 contacts about that.

--
You received this message because you are subscribed to the Google Groups "Smooks Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-user+unsubscribe@googlegroups.com.
To post to this group, send email to smook...@googlegroups.com.

Rakshitha Shetty

unread,
Jan 27, 2017, 10:33:35 AM1/27/17
to Smooks Users
Oh okay. Let me check that out from my wso2 contacts. Thank you so much for the response.




On Wednesday, January 25, 2017 at 5:29:42 PM UTC+5:30, Tom Fennelly wrote:
That's actually what I mean. The fact that the SAX filter is producing entity references is actually right. If something after that step in the process wants to output that data in a different format (in your case JSON), then it's the responsibility of that something to remove entities or other that are not right for that format. I hope I'm making sense.

So ... you need some way of stripping the entities before they make it into the JSON. I think you need to talk to your wso2 contacts about that.
On 25 January 2017 at 11:27, Rakshitha Shetty <srakshit...@gmail.com> wrote:
Tom Fennelly,

Thanks for your response.

No it is escaping the xml entities in the generated JSON.

like i have a payload which says user first name is tina's

the json output gives it as { first_name: tina&amp;s }

this is nothing to do with the JSON generation. 

json generation is fine in places where i am not using a sax filter

I went through few more articles that said SAX filter would escape the xml characters.

below links are for your reference

http://stackoverflow.com/questions/26265389/how-do-i-stop-smooks-from-escaping-ampersand

http://milyn.996300.n3.nabble.com/How-do-I-prevent-smooks-from-escaping-ampersands-td8930.html

and finally  i have not got in touch with wso2 people yet.

--
You received this message because you are subscribed to the Google Groups "Smooks Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-user...@googlegroups.com.

To post to this group, send email to smook...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages