Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

CDATA Encoding/Decoding

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CDATA Encoding/Decoding

    My Mirth Channel is receiving data from a web service which packages multiple fields into a CDATA region. The data that comes back is obviously encoded, for example:



    It's elements are therefore not accessible through the Message tree (if i use an example message as my template) as they are seen as a string within this region.

    I guess my questions are:
    1) Is there an encoder.decode() function that can be called from Javascript?
    2) Is there a best practice for handling CDATA decoding?
    3) Has anyone run across this and, if so, how did you go about accessing the data within?

    Thanks to everyone for reading/helping. I appreciate all of the help I have been given on this forum!!
    Jason

    Post edited by: jason.irwin, at: 07/15/2008 09:27

    Post edited by: jason.irwin, at: 07/15/2008 09:30

  • #2
    Re:CDATA Encoding/Decoding

    jason.irwin wrote:
    I guess my questions are:
    1) Is there an encoder.decode() function that can be called from Javascript?
    2) Is there a best practice for handling CDATA decoding?
    3) Has anyone run across this and, if so, how did you go about accessing the data within?
    1) Yes, I'm not sure where it is though.

    3) You'll probably just want to stuff a call to decode the field in a javascript step in the transformer if that only occurs in certain fields. If it is all over the message put it in the preprocessor to decode it before it gets turned into XML.
    Jon Bartels

    Zen is hiring!!!!
    http://consultzen.com/careers/
    Talented healthcare IT professionals wanted. Engineers to sales to management.
    Good benefits, great working environment, genuinely interesting work.

    Comment


    • #3
      Re:CDATA Encoding/Decoding

      I've run into this issue in order to handle some message format that are not XML nor hl7. So these message were wrapped in a CDATA region prior to the message processing.

      In my scenario I've copied the whole CDATA region into a new variable, and then parsing it as usual: instead of msg[MSG][MSH.9]...

      var payload = msg[CDATA_SECTION];
      var username = payload[user];

      and so on ..

      Hope that helps

      In my scenario, the CDATA wrapping was done to skip hl7/xml parser validations in the original msg and to skip tilde chars and other non-ascii chars or "<".

      Comment


      • #4
        Add a JavaScript step and..

        First, extract the payload into a variable in the source transformation.

        In the destination transformation, create a JavaScript step and...

        channelMap.put('payload',decodeURIComponent($('pay load')));

        ${payload} should now be decoded..

        Comment


        • #5
          removing CDATA wrapper

          I just put this in the pre-processor script...

          // A CDATA section starts with "<![CDATA[" and ends with "]]>":
          if((message.indexOf("<![CDATA[") === 0) && (message.substring(message.length-3) === "]]>")) {
          message = message.substring(9, message.length-3);
          }

          Comment

          Working...
          X