8 Replies Latest reply on Feb 7, 2012 3:40 AM by Eduardo de Vera Toquero

    xsl:param support

    Eduardo de Vera Toquero Newbie

      Hi,

       

      I would like to know if there is any support for xsl:param in either the XsltAction or the SmooksAction. As you might already know, xsl:param provides a mean to expose parameters in order to set them when calling the transformer.

       

      I am currently involved in a project where this is a need and I have made a custom action that leverages the Transformer object and supplies values from the ESB Message body payload to the xsl:param(eters) of the xslt transformation source. I wonder if there is any interest in the community in order to integrate this behavior into the XsltAction or SmooksAction.

        • 1. xsl:param support
          Sven-Jørgen Karlsen Newbie

          Hi,

          I'm interested. I occasionally have the need for xsl:params, so it would be great

          to avoid inventing yet another XsltAction the next time.

           

          Btw. perhaps it's an idea to support both static and dynamic parameter passing? That is, parameters can be

          fetched from both the JBoss ESB configuration (the ConfigTree) and dynamically from somewhere in the ESB

          message.

           

           

          Regards,

           

          Sven-Jørgen Karlsen

          • 2. xsl:param support
            Tom Fennelly Master

            Hi Eduardo.

             

            These sounds like good enhancements and I think others have asked for them in the past.  Does your custom action use/modify XsltAction?  Ideally, we'd like to get these enhancements on the XsltAction.  If you could supply a patch to XsltAction that adds these, attaching the patch to an enhancement jira, then we can look at adding them to JBoss ESB.

            • 3. Re: xsl:param support
              Eduardo de Vera Toquero Newbie

              Hi Tom,

               

              The Jira enhancement issue I have created can be located here:

               

              https://issues.jboss.org/browse/JBESB-3587

               

              I need some time in order to create the patch as the work I have done until now is not very standard in JBoss terms (it depends on a properties file configured in the ConfigTree instead of being fully integrated with the configuration of JBoss ESB). It also relies on the fact that the value to pass the xslt:parameter is a string and that it always is being taken from the ESB message.

               

              I will try to refactor this and create a patch that I will upload to the Jira issue hoping to have some committer pick it up and commit it to the JBoss ESB sources.

              • 4. Re: xsl:param support
                Eduardo de Vera Toquero Newbie

                I just uploaded a patch with this functionality.

                It is important to remark the fact that the value for the xslt parameters must be a string and that it should be placed in the message.

                • 5. Re: xsl:param support
                  Jean-Marc Reymond Newbie

                  Hi Eduardo,

                   

                   

                  And thanks for your patch!

                  I am trying to use it in my project but I am having trouble understanding how to declare things.

                   

                  Here is what I have in my jboss-esb.xml for the given action:

                  <action name="action1" class="com.common.XsltActionDynamicParams">

                      <property name="get-payload-location" value="CanonicalRequest" />

                      <property name="set-payload-location" value="OutRequest" />

                      <property name="templateFile" value="/Canonical-to-OutRequest.xsl" />

                      <property name="resultType" value="STRING" />

                      <property name="xslt-param">

                          <property name="name" value="dyn_param"/>

                          <property name="value" value="my_value"/>

                      </property>

                  </action>

                   

                   

                  And in my Canonical-to-OutRequest.xsl I have:

                  ....

                  <xsl:template match="/">

                      <myelement>${dyn_param}</myelement>

                  </xsl:template>

                  ....

                   

                   

                  Can you confirm that I use/declare things correctly?

                   

                   

                  Thanks!

                  • 6. Re: xsl:param support
                    Jean-Marc Reymond Newbie

                    To answer the second part of my question, Canonical-to-OutRequest.xsl has to look like this:

                     

                    <xsl:param name="dyn_param" select="'1234'"/>

                    <xsl:template match="/">

                        <myelement><xsl:value-of select="$dyn_param"/></myelement>

                    </xsl:template>

                    • 7. Re: xsl:param support
                      Jean-Marc Reymond Newbie

                      And to answer the first part of my question, the given action in jboss-esb.xml should look like this:

                      <action name="action1" class="com.common.XsltActionDynamicParams">

                          <property name="get-payload-location" value="CanonicalRequest" />

                          <property name="set-payload-location" value="OutRequest" />

                          <property name="templateFile" value="/Canonical-to-OutRequest.xsl" />

                          <property name="resultType" value="STRING" />

                          <property name="xslt-params">

                              <xslt-param name="dyn_param" value="my_value_holder"/>

                              <xslt-param name="dyn_param2" value="my_value_holder2"/>

                          </property>

                      </action>

                       

                      dyn_param is the name of the parameter you will use in your XSL file.

                      my_value_holder is the name of the variable in your message holding your dynamic value.

                      • 8. Re: xsl:param support
                        Eduardo de Vera Toquero Newbie

                        Hi Jean-Marc,

                         

                        I have just realized your comments here. I see that you have solved your problems by yourself and I hope that sooner rather than later the patch is applied to the JBoss ESB product.

                         

                        Best regards,

                        Eduardo de Vera