Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In destination templates, XmlUtil.encode does not work when passed in the result of an XSLT step #3015

Closed
rbeckman-nextgen opened this issue May 11, 2020 · 6 comments
Milestone

Comments

@rbeckman-nextgen
Copy link
Collaborator

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

This is because what's actually placed into the map is a StringWriter object, not a String. Referencing the variable directly like ${result} is "fine", because Velocity automatically calls the toString() function. However when you pass that variable into another function first, like, $XmlUtil.encode($result), that result variable remains untouched, and because XmlUtil has no encode method that takes in a StringWriter, Velocity throws an exception and the context is aborted. So instead of actually doing the replacement, you'll see the Velocity syntax verbatim in the sent data.

Imported Issue. Original Details:
Jira Issue Key: MIRTH-3100
Reporter: narupley
Created: 2013-12-17T07:33:32.000-0800

@rbeckman-nextgen rbeckman-nextgen added this to the 3.3.0 milestone May 11, 2020
@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

To fix, the client needs to add a .toString() in the XSLT script so that a string is placed in the channel map, rather than a StringWriter.

Imported Comment. Original Details:
Author: narupley
Created: 2013-12-17T07:35:19.000-0800

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

In the meantime a workaround is to use ${XmlUtil.encode(${result.toString()})} in your destination template, instead of ${XmlUtil.encode(${result})}.

Imported Comment. Original Details:
Author: narupley
Created: 2013-12-17T07:46:35.000-0800

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

The result of XSLT steps is now converted to String before added to the channel map.

Imported Comment. Original Details:
Author: leilanim
Created: 2015-06-16T12:03:50.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

To create a XSLT transformer step

  1. Click edit channel
  2. Goto either source or destination tab
  3. Click edit transformer
  4. Click add step
  5. Change the transformer type (by default it is "Mapper") to XSLT Step
  6. Fill in the fields.

For this test, I used the XSLT script and XML message from
http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog_choose

Imported Comment. Original Details:
Author: minht
Created: 2015-08-19T16:38:34.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Server(s) and URLs Used: Run Mirth Connect on local OSX Yosemite 10.10
Version(s)/Build(s) to reproduce failure: mirthconnect-3.2.2.7680.b56-unix
Version(s)/Build(s) to verify new feature: mirthconnect-3.3.0.7719.b1682-unix
How Tested (list tests run):

  • Start Mirth Connect
  • Create channel:
    Source = Channel Reader with XSLT transformer step that would convert XML to XML.
    Destination = Channel Writer with template ${XmlUtil.prettyPrint(${xsltTranformedMsg})}
  • Deploy channel
  • Send XML message
  • Check server.log for any error
  • Verify the source and destination message
    ** Destination > Sent > [CONTENT] should show XML format data

Verified:
see screenshots for comparison
Old Build Sent Message [CONTENT] ${XmlUtil.prettyPrint(${xsltTranformedMsg})}
New Build Sent Message ` [CONTENT]

My CD Collection

… `

Imported Comment. Original Details:
Author: minht
Created: 2015-08-19T16:57:09.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Successfully verified with mirthconnect-3.3.0.7719.b1682-unix

Imported Comment. Original Details:
Author: minht
Created: 2015-08-19T17:12:27.000-0700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.