6 Replies Latest reply on Oct 26, 2007 9:46 AM by Eric Cartman

    Smooks and Freemarker

    Eric Cartman Newbie

      I'm testing Smooks and Freemarker. I can't figure out how to process a simple xml.

      For example:


      Dalian, China (ZYTL) 38-54N 121-38E 97M
      Oct 25, 2007 - 10:00 AM EDT / 2007.10.25 1400 UTC
      from the W (280 degrees) at 4 MPH (4 KT) (direction variable):0
      less than 1 mile:0
      obscured
      55 F (13 C)
      55 F (13 C)
      100%
      30.15 in. Hg (1021 hPa)
      Success



      With this FTL transformation:

      <?xml version='1.0' encoding='UTF-8'?>
      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">

      <resource-config selector="CurrentWeather">

      <![CDATA[${Temperature}]]>

      replace
      </resource-config>

      </smooks-resource-list>


      PLEASE....HELP...... I'm crazy with this thing !!!!

      PD: I already tested with XSL and works fine with:
      <resource-config selector="CurrentWeather">

      <![CDATA[<xsl:value-of select="./Temperature" />]]>

      true
      </resource-config>

        • 1. Re: Smooks and Freemarker
          Eric Cartman Newbie

          Ups, this is the example xml:

          <CurrentWeather>
           <Location>Dalian, China (ZYTL) 38-54N 121-38E 97M</Location>
           <Time>Oct 25, 2007 - 10:00 AM EDT / 2007.10.25 1400 UTC</Time>
           <Wind> from the W (280 degrees) at 4 MPH (4 KT) (direction variable):0</Wind>
           <Visibility> less than 1 mile:0</Visibility>
           <SkyConditions> obscured</SkyConditions>
           <Temperature> 55 F (13 C)</Temperature>
           <DewPoint> 55 F (13 C)</DewPoint>
           <RelativeHumidity> 100%</RelativeHumidity>
           <Pressure> 30.15 in. Hg (1021 hPa)</Pressure>
           <Status>Success</Status>
          </CurrentWeather>


          • 2. Re: Smooks and Freemarker
            Eric Cartman Newbie

            Again:

            XSL - WORKING OK

            <resource-config selector="CurrentWeather">
             <resource type="xsl">
             <![CDATA[<FONT FACE="MS Sans Serif"><FONT COLOR="#000000"><xsl:value-of select="./Temperature" /></FONT></FONT>]]>
             </resource>
             <param name="is-xslt-templatelet">true</param>
             </resource-config>


            FLT - NOT WORKING

            <resource-config selector="CurrentWeather">
             <resource type="ftl">
            <![CDATA[<FONT FACE="MS Sans Serif"><FONT COLOR="#000000">${Temperature}</FONT></FONT>]]>
             </resource>
             <param name="action">replace</param>
             </resource-config


            Thanks,
            Eric

            • 3. Re: Smooks and Freemarker
              Tom Fennelly Master

              Have you tried this sample on the Smooks website... download it and run it.

              • 4. Re: Smooks and Freemarker
                Eric Cartman Newbie


                I reviewed it. I don't have an object model to populate.

                I'm receving a XML and transforming it to a text.

                It's related with:

                freemarker - Part III. XML Processing Guide
                http://freemarker.org/docs/xgui.html

                freemarker - Putting the XML into the data model
                http://freemarker.org/docs/xgui_expose_put.html

                /* Create a data model */
                Map root = new HashMap();
                root.put(
                 "doc",
                 freemarker.ext.dom.NodeModel.parse(new File("the/path/of/the.xml")));
                


                But the XML comes from ESB, loaded by org.jboss.soa.esb.actions.converters.SmooksTransformer

                So... where is the absolute reference to the data ? It seems selector is working, but not the variable Temperature reference.


                Thank,
                Eric

                • 5. Re: Smooks and Freemarker
                  Tom Fennelly Master

                  OK, Smooks doesn't support this usage model at the moment... it only supports the normal java model based approach. See FreeMarkerContentDeliveryUnitCreator for details on how FreeMarker is integrated.

                  Smooks will (at some stage) have support for "virtual models", which means you won't actually require a physical java object model.

                  • 6. Re: Smooks and Freemarker
                    Eric Cartman Newbie


                    Ok, I'll open a JIRA feature request.

                    In the meantime, I'll manage to use XSL transformation.

                    Thanks for you answer,
                    Eric