8 Replies Latest reply on Apr 17, 2008 5:27 PM by Andreas Watler

    recent Smooks changes

    Andreas Watler Newbie

      Hi,

      I have a question about the recent Smooks update.

      I have a XSLT Stylesheet, that doesn't work any more.
      I think it worked before the update, but I'm not 100% sure,
      because I haven't used it in a while.

      Anyways when i execute the transformation (with the converters.SmooksTransformer action)
      I get a error message that says something like:

      "Unknown System-ID....
      Can not convert #RTREEFRAG to a NodeList!"

      as an "ERROR [STDERR]" output
      (well the whole thing is in german, but thats essentially it).

      I narrowed it down to a point, where I access a certain variable,
      I build up from parts of the source XML.
      Like I said, I think that worked before, but can't be sure.

      Could it be that there where some significant changes in Smooks,
      and if so, for what do I have to look in my Transformations to change accordingly?

      Thanks
      Andreas

        • 1. Re: recent Smooks changes
          Daniel Bevenius Master

          Hi Andreas,

          There hasn't been any major updates to the way Smooks handles xslt only one that I know of, and the had to do with namespaces support. I'll get Tom to comment on this aswell.

          Can you provide us with some more information, like your Smooks configuration file, the input xml and we'll take a look.

          You can also try modifiying one of the examples in the Smooks project to try out your transfoms with it. You could try either :
          xslt-basic
          xslt-namespaces.
          You can find them here: http://milyn.codehaus.org/Tutorials


          Regards,

          Daniel

          • 2. Re: recent Smooks changes
            Tom Fennelly Master

            The only functional change to XSLT support is wrt reporting/failing on XSLT warnings and errors. Pre Smooks 1.0, it carried on regardless of XSLT errors/warnings i.e. we didn't have an error listener attached. We changed this in 1.0 and added the listener and are reporting/failing on the errors. However, you can turn this off and revert back to the old functionality by setting the "failOnWarning" param (on the XSLT resource config) to "false". See the XslContentHandlerFactory Javadocs.

            Also, you said you weren't sure if this XSLT worked before. Would you mind checking ;-)

            • 3. Re: recent Smooks changes
              Andreas Watler Newbie

              Hi,

              so I tried that param, and now I get a result again.
              The error messages are still there, and the part of the transformation where they originate doesn't work, but the rest is there.
              I'm guessing this is how it worked before, like I said, I haven't checked that in a while.

              Since I only wanted to do some performance tests with this, and don't really use it any more, this would be ok for me now.
              But if you could tell me, what revision to check out, to get an ESB preceding the changes, I'll might try it with the old version too.

              As for the examples:
              I don't really know, if I can give you the real ones, but I have thrown a example together, illustrating what I'm trying to do.

              XML:

              <root>
               <ent1>
               <refs>
               <refEnt2 ref="01"/>
               </refs>
               </ent1>
               .......
               <ent2 id="01">
               <ent2sub></ent2sub>
               </ent2>
               <ent2 id="02">
               <ent2sub></ent2sub>
               </ent2>
               .....
              </root>
              


              XSLT:
              
               <xsl:template match="root">
               <xsl:variable name="ent2s" select="ent2"/>
               .....
               <xsl:for-each select="ent1">
               .....
               <xsl:variable name="ent2subs" >
               <xsl:for-each select="refs/refEnt2">
               <xsl:variable name="refID">
               <xsl:value-of select="@ref"/>
               </xsl:variable>
               <xsl:for-each select="$ent2s[@id=$refID]">
               <xsl:if test="ent2sub">
               <ent2sub>
               <xsl:value-of select="ent2sub"/>
               </ent2sub>
               </xsl:if >
               </xsl:for-each>
               </xsl:for-each>
               </xsl:variable>
               <xsl:comment> <xsl:value-of select="count($ent2subs/ent2sub)"/>ent2subs found</xsl:comment>
              
              ....variable is accessed here serveral times, but that code is never reached even with "failOnWarning = false"
               </xsl:for-each>
               </xsl:template>
              


              Smooks-Conf:
               <resource-config selector="$document">
               <resource type="xsl">path/to.xslt</resource>
               <param name="is-xslt-templatelet">false</param>
               <param name="VisitPhase">ASSEMBLY</param>
               <param name="encoding">ISO-8859-1</param>
               <param name="failOnWarning">false</param>
               </resource-config>
              


              Might be, that this is just wrong, but I tested it with another processor, and it worked there.

              On a side note, I posted a question on the Smooks-selector once
              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=130377
              and wanted to ask about that again, because this is an issue here too.

              Like I said, I don't really need that whole transformation any more,
              and I don't want to sink that much time in it either.
              But I thought it would be nice to get it to work somehow.

              Thanks & regards
              Andreas

              • 4. Re: recent Smooks changes
                Tom Fennelly Master

                 

                "standard" wrote:
                I tested it with another processor, and it worked there.


                That's XSL for you :-) I can't omit support for XSL from Smooks, but sometimes I wish I could. Stinking pile of...... ;-)

                BTW... have you read this... specifically the "Points to Note Regarding XSL Support" and "My XSLT Works Outside Smooks, but not Inside?" sections.

                • 5. Re: recent Smooks changes
                  Andreas Watler Newbie

                   

                  Stinking pile of...... ;-)


                  I hear you :-) I learned to hate it the last few months.

                  Well I read your link and don't see where I'm wrong.
                  The template itself shouldn't be wrong, since everything else in it works,
                  and I don't think that I am using any absolute pathes.

                  Anyways, I think I'll do my tests with it the way it is now,
                  since I'm only interested in performance here,
                  and that shouldn't be that far off a working solution (and if it is, **** it).
                  The solution I used here (first XSLT, then Groovy) was a bad idea in the first place,
                  never worked right, and was a pain in the *** to develop (both because of XSLT and Groovy).
                  Thats why I dumped it weeks ago, and only wanted to compare it now with my real solution in terms of performance.

                  The real work I do with BeanPopulation and FreeMarker now,
                  which is way cool (develop, test and maintain), and works like a charm.
                  I think it was you who suggested that in the first place, some time ago,
                  so thanks again for that :-).

                  I'm still interested in these Smooks-selectors, but only out of curiosity now.

                  Thanks and regards
                  Andreas



                  • 6. Re: recent Smooks changes
                    Tom Fennelly Master

                     

                    "standard" wrote:
                    The real work I do with BeanPopulation and FreeMarker now, which is way cool (develop, test and maintain), and works like a charm.
                    I think it was you who suggested that in the first place, some time ago,
                    so thanks again for that :-).


                    Yep, that does work really well and is far more intuitive than XSLT.

                    Also note that for big/large message (> 100Mb), this approach will still work, whereas all XSLT Processors I've tried (Xalan, Saxon and XSLTC i.e. the main ones) fall over with OOM errors. With Smooks + a Model Driven transform (using e.g. FreeMarker for the templating), you can easily process Gb size messages (i.e. huge messages).

                    "standard" wrote:
                    I'm still interested in these Smooks-selectors, but only out of curiosity now.


                    Smooks only supports element based selector. It doesn't support down to attributes yet, but that is something we might add. Smooks v0.9 only supported contextual selectors of the CSS form, but v1.0 supports CSS or XPath (ish) style contextual selectors (e.g. "a/b/c").

                    • 7. Re: recent Smooks changes
                      Tom Fennelly Master

                      ... and yes... we were using SteamSources into the XSLT Processors for those large messages :-)

                      • 8. Re: recent Smooks changes
                        Andreas Watler Newbie

                         

                        Also note that for big/large message (> 100Mb), this approach will still work, whereas all XSLT Processors I've tried (Xalan, Saxon and XSLTC i.e. the main ones) fall over with OOM errors. With Smooks + a Model Driven transform (using e.g. FreeMarker for the templating), you can easily process Gb size messages (i.e. huge messages).


                        Thats pretty cool, and might actually come in handy here :-).

                        Thanks for the infos
                        Andreas