Announcement

Collapse
No announcement yet.

XSLT Transform Issue

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

  • XSLT Transform Issue

    Hi everyone,

    I am running Mirth version 1.8.2.4472. I have a channel setup using the XSLT Step Transformer. I set the source XML string to "msg" and the result to "output". The XSLT has been confirmed to work on other conversion software (specifically Xselerator). However when I run it in Mirth I get this error:

    ERROR-300: Transformer error
    ERROR MESSAGE: Error evaluating transformer
    com.webreach.mirth.server.MirthJavascriptTransform erException:
    CHANNEL: JPU-C32 Transform
    CONNECTOR: sourceConnector
    SCRIPT SOURCE:
    SOURCE CODE:
    1: function validate(mapping, defaultValue, replacement) {var result = mapping;if ((result == undefined) || (result.toString().length == 0)) { if (defaultValue == undefined) { defaultValue = ''} result = defaultValue; } result = new java.lang.String(result.toString()); if (replacement != undefined) {for (i = 0; i < replacement.length; i++) { var entry = replacement[i]; result = result.replaceAll(entry[0], entry[1]); } } return result; }String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,"").replace(/^\t+|\t+$/g,""); };function $(string) { if (connectorMap.containsKey(string)) { return connectorMap.get(string); }else if (channelMap.containsKey(string)) { return channelMap.get(string); }else if (globalMap.containsKey(string)) { return globalMap.get(string); }else { return ''; }}function $g(key, value) {if (arguments.length == 1) { return globalMap.get(key); }else if (arguments.length == 2) { globalMap.put(key, value); }}function $c(key, value) {if (arguments.length == 1) { return channelMap.get(key); }else if (arguments.length == 2) { channelMap.put(key, value); }}function $co(key, value) {if (arguments.length == 1) { return connectorMap.get(key); }else if (arguments.length == 2) { connectorMap.put(key, value); }}function $r(key, value) {if (arguments.length == 1) { return responseMap.get(key); }else if (arguments.length == 2) { responseMap.put(key, value); }}function createSegment(name, msgObj, index) {if (arguments.length == 1) { return new XML('<' + name + '></' + name + '>'); };if (arguments.length == 2) { index = 0; };msgObj[name][index] = new XML('<' + name + '></' + name + '>'); return msgObj[name][index];}function createSegmentAfter(name, segment) {var msgObj = segment;while (msgObj.parent() != undefined) { msgObj = msgObj.parent(); }msgObj.insertChildAfter(segment[0], new XML('<' + name + '></' + name + '>'));}function getAttachments() {return Packages.com.webreach.mirth.server.controllers.Con trollerFactory.getFactory().createMessageObjectCon troller().getAttachmentsByMessageId(messageObject. getId());}function addAttachment(data, type) {var attachment = Packages.com.webreach.mirth.server.controllers.Con trollerFactory.getFactory().createMessageObjectCon troller().createAttachment(data, type, messageObject);messageObject.setAttachment(true);P ackages.com.webreach.mirth.server.controllers.Cont rollerFactory.getFactory().createMessageObjectCont roller().insertAttachment(attachment);
    2: return attachment;
    3: }
    4: XML.ignoreWhitespace=true;XML.prettyPrinting=false ;var newMessage = message.replace(/xmlns:?[^=]*=[""][^""]*[""]/g, '');
    5: msg = new XML(newMessage);
    6: if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
    7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);
    8:
    9:
    10: tFactory = Packages.javax.xml.transform.TransformerFactory.ne wInstance();xsltTemplate = new Packages.java.io.StringReader(<?xml version="1.0" encoding="utf-8"?>
    LINE NUMBER: 6
    DETAILS: TypeError: The prefix "z" for element "z:row" is not bound.
    at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateScript(JavaScriptTransform er.java:458)
    at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.transform(JavaScriptTransformer.ja va:356)
    at org.mule.transformers.AbstractEventAwareTransforme r.doTransform(AbstractEventAwareTransformer.java:4 8)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:197)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
    at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
    at org.mule.routing.inbound.SelectiveConsumer.isMatch (SelectiveConsumer.java:61)
    at org.mule.routing.inbound.InboundMessageRouter.rout e(InboundMessageRouter.java:83)
    at org.mule.providers.AbstractMessageReceiver$Default InternalMessageListener.onMessage(AbstractMessageR eceiver.java:493)
    at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:272)
    at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:231)
    at com.webreach.mirth.connectors.file.FileMessageRece iver.processFile(FileMessageReceiver.java:233)
    at com.webreach.mirth.connectors.file.FileMessageRece iver.poll(FileMessageReceiver.java:123)
    at org.mule.providers.PollingMessageReceiver.run(Poll ingMessageReceiver.java:90)
    at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
    at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.runTask(ThreadPoolExecutor. java:650)
    at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.run(ThreadPoolExecutor.java :675)
    at java.lang.Thread.run(Thread.java:717)


    It has something to to with the z:row elements of the input xml. The z is a namespace with xmlns:z = "#RowSetSchema" defined in the input XML file. I've searched the forums but I'm not sure if the solution to this problem lies in using a different parser, somehow enabling namespaces, or...? I am using a file reader and file writer for my I/O channels. Thanks for any advice you can offer!

  • #2
    closer...

    So I finally found the "strip namespaces" option for input and output, and unchecked them both. However now when I run the channel I still get an error before any transformation even starts. See:

    ERROR-300: Transformer error
    ERROR MESSAGE: Error evaluating transformer
    com.webreach.mirth.server.MirthJavascriptTransform erException:
    CHANNEL: JPU-C32 Transform
    CONNECTOR: sourceConnector
    SCRIPT SOURCE:
    SOURCE CODE:
    3420: </component>
    3421: </structuredBody>
    3422: </component>
    3423: </ClinicalDocument>
    3424: </xsl:template>
    3425: </xsl:stylesheet>);transformer = tFactory.newTransformer(new Packages.javax.xml.transform.stream.StreamSource(x sltTemplate));sourceVar = new Packages.java.io.StringReader(msg);resultVar = new Packages.java.io.StringWriter();transformer.transf orm(new Packages.javax.xml.transform.stream.StreamSource(s ourceVar), new Packages.javax.xml.transform.stream.StreamResult(r esultVar));channelMap.put('output', resultVar)
    3426:
    3427: }
    LINE NUMBER: 3425
    DETAILS: Wrapped javax.xml.transform.TransformerConfigurationExcept ion: Could not load the translet class 'GregorSamsa'.
    at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateScript(JavaScriptTransform er.java:458)
    at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.transform(JavaScriptTransformer.ja va:356)
    at org.mule.transformers.AbstractEventAwareTransforme r.doTransform(AbstractEventAwareTransformer.java:4 8)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:197)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
    at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
    at org.mule.routing.inbound.SelectiveConsumer.isMatch (SelectiveConsumer.java:61)
    at org.mule.routing.inbound.InboundMessageRouter.rout e(InboundMessageRouter.java:83)
    at org.mule.providers.AbstractMessageReceiver$Default InternalMessageListener.onMessage(AbstractMessageR eceiver.java:493)
    at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:272)
    at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:231)
    at com.webreach.mirth.connectors.file.FileMessageRece iver.processFile(FileMessageReceiver.java:233)
    at com.webreach.mirth.connectors.file.FileMessageRece iver.poll(FileMessageReceiver.java:123)
    at org.mule.providers.PollingMessageReceiver.run(Poll ingMessageReceiver.java:90)
    at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
    at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.runTask(ThreadPoolExecutor. java:650)
    at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.run(ThreadPoolExecutor.java :675)
    at java.lang.Thread.run(Thread.java:717)
    Caused by: javax.xml.transform.TransformerConfigurationExcept ion: Could not load the translet class 'GregorSamsa'.
    at com.sun.org.apache.xalan.internal.xsltc.trax.Templ atesImpl.defineTransletClasses(TemplatesImpl.java: 335)
    at com.sun.org.apache.xalan.internal.xsltc.trax.Templ atesImpl.getTransletInstance(TemplatesImpl.java:35 3)
    at com.sun.org.apache.xalan.internal.xsltc.trax.Templ atesImpl.newTransformer(TemplatesImpl.java:386)
    at com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl.newTransformer(TransformerFactor yImpl.java:633)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:613)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:161)
    at org.mozilla.javascript.NativeJavaMethod.call(Nativ eJavaMethod.java:247)
    at org.mozilla.javascript.optimizer.OptRuntime.call1( OptRuntime.java:66)
    at org.mozilla.javascript.gen._4c1cc9f7_c1ac_4cff_b75 f_b078199332ea_226._c_doTransform_13(4c1cc9f7-c1ac-4cff-b75f-b078199332ea:3425)
    at org.mozilla.javascript.gen._4c1cc9f7_c1ac_4cff_b75 f_b078199332ea_226.call(4c1cc9f7-c1ac-4cff-b75f-b078199332ea)
    at org.mozilla.javascript.optimizer.OptRuntime.callNa me0(OptRuntime.java:108)
    at org.mozilla.javascript.gen._4c1cc9f7_c1ac_4cff_b75 f_b078199332ea_226._c_script_0(4c1cc9f7-c1ac-4cff-b75f-b078199332ea:3428)
    at org.mozilla.javascript.gen._4c1cc9f7_c1ac_4cff_b75 f_b078199332ea_226.call(4c1cc9f7-c1ac-4cff-b75f-b078199332ea)
    at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:426)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3157)
    at org.mozilla.javascript.gen._4c1cc9f7_c1ac_4cff_b75 f_b078199332ea_226.call(4c1cc9f7-c1ac-4cff-b75f-b078199332ea)
    at org.mozilla.javascript.gen._4c1cc9f7_c1ac_4cff_b75 f_b078199332ea_226.exec(4c1cc9f7-c1ac-4cff-b75f-b078199332ea)
    at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateScript(JavaScriptTransform er.java:403)
    ... 18 more

    What is the GregorSamsa translet class and how does it relate to my channel? Thanks a lot!

    Comment


    • #3
      GregorSamsa is a built in java class for xslt transformations. As it can't be accessed, it suggests a Java version/installation issue. Are you running the correct Java version for your Mirth install?

      Mirth will have to point you in the right direction beyond this. This is just one place to start looking. Good luck!
      Jimmy
      - Denver, Colorado

      Comment


      • #4
        Solved

        Actually it turns out the issue is an unresolved bug in the Xalan processor. It won't process stylesheets larger than the JVM limit of 64 KB. While if you look around the web, you'll see some references to this being fixed, in fact it is not as of Xalan 2.7.1, which I have with my JDK. Cutting the XSLT down in size without making significant functional changes solved the problem. Thanks for the response though!

        Comment


        • #5
          Good to know. Glad you figured it out! Now the question is being able to process larger stylesheets. What JVM are you using...??? just so we know what versions are affected by the bug.
          Jimmy
          - Denver, Colorado

          Comment


          • #6
            System Stuff

            I'm using JRE version 6, I downloaded Java about a month ago.

            Comment


            • #7
              Originally posted by Mireth View Post
              I'm using JRE version 6, I downloaded Java about a month ago.
              Curious what the official response will be from the developers on this...
              Jimmy
              - Denver, Colorado

              Comment


              • #8
                On apache.org: https://issues.apache.org/jira/browse/XALANJ-1549

                ^^As you can see the bug is listed as unresolved and is currently under development. Anyone working with healthcare transforms large scale and using XSLT will probably have ones that exceed this size limit, so it's definitely something to look out for.

                Comment


                • #9
                  Awesome! Thanks for the heads up!
                  Jimmy
                  - Denver, Colorado

                  Comment

                  Working...
                  X