Skip to Content
author's profile photo Former Member
Former Member

Escaping ' and " characters in XML message

Hello,

I have the following issue with XML character escaping. The following characters need to be escaped: < > & ' and ".

When I receive the message in the integration engine &lt and &gt are already escaped as expected. However ' and " are not.

I have implemented a Java Mapping to replace " and ' with it escape characters & quot; and & apos;

Problem however is that ALL " are escaped (including the XML prolog xml version = "1.0" )

The XML then results in a parsing error when executing a test for the mapping.

Do you have any idea how I can resolve this?`

Thank you very much!

Edited by: Florian Guppenberger on Jan 20, 2010 10:49 PM

Edited by: Florian Guppenberger on Jan 20, 2010 10:49 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jan 20, 2010 at 10:18 PM

    Hi Florian,

    why reinvent the wheel ?:)

    type : escaping java in google and take any of the many examples as your java mapping 😊

    escaping is totally not PI specific

    Regards,

    Michal Krawczyk

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 21, 2010 at 04:24 AM

    Hi Florian,

    You can change the Unicode in Adapter engine from UTF8 to ISO... it supports &

    the other solution is you can replace your & with some constant (like!!!!@!!!!!) using java mapping and at the receiver end you replace !!!!@!!!! with & to show the end user the exact string.

    Thanks,

    Sunil Singh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 21, 2010 at 09:31 AM

    Usually there is no need for escaping ' and ", as the XML is valid anyway.

    I think you should use a SAX parser. The SAX parser divides the XML in tags, namespaces and elements.

    So you can do the String replace routines on element level only.

    Regards

    Stefan

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.