Uploaded image for project: 'JBoss Enterprise SOA Platform'
  1. JBoss Enterprise SOA Platform
  2. SOA-3061

Freemarker error when input files contains namespace declaration

    XMLWordPrintable

    Details

    • Steps to Reproduce:
      Hide

      1. Deploy attached modified transform_XML2XML quickstart
      2. Run 'ant runsuccess' to try the Freemarker template based transformation. The input file SampleOrder.xml (which contains no namespace declaration) is used for this.
      3. Run 'ant runfailure', which uses the input file SampleOrderFailure.xml (which contains namespace declaration) to reproduce the error.

      Show
      1. Deploy attached modified transform_XML2XML quickstart 2. Run 'ant runsuccess' to try the Freemarker template based transformation. The input file SampleOrder.xml (which contains no namespace declaration) is used for this. 3. Run 'ant runfailure', which uses the input file SampleOrderFailure.xml (which contains namespace declaration) to reproduce the error.
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      Until there is a way to strip the namespace from the DOM fragment that has been created by the DomModelCreator, a workaround would be to remove the namespace from the incoming document before the SmooksAction, using XSLT:

      jboss-esb.xml:
      -------------
      <!-- Remove namespace from input document before the SmooksAction -->
      <action name="remove-namespace-using-xslt" class="org.jboss.soa.esb.actions.transformation.xslt.XsltAction">
      <property name="templateFile" value="/smooks.xsl"/>
      </action>
      <action name="simple-transform" class="org.jboss.soa.esb.smooks.SmooksAction">
      <property name="smooksConfig" value="/smooks-res.xml" />
      </action>

      smooks.xsl:
      -------------
      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes"/>

      <xsl:template match="/|comment()|processing-instruction()">
      <xsl:copy>
      <xsl:apply-templates/>
      </xsl:copy>
      </xsl:template>

      <xsl:template match="*">
      <xsl:element name="

      {local-name()}">
      <xsl:apply-templates select="@*|node()"/>
      </xsl:element>
      </xsl:template>

      <xsl:template match="@*">
      <xsl:attribute name="{local-name()}

      ">
      <xsl:value-of select="."/>
      </xsl:attribute>
      </xsl:template>
      </xsl:stylesheet>

      Show
      Until there is a way to strip the namespace from the DOM fragment that has been created by the DomModelCreator, a workaround would be to remove the namespace from the incoming document before the SmooksAction, using XSLT: jboss-esb.xml: ------------- <!-- Remove namespace from input document before the SmooksAction --> <action name="remove-namespace-using-xslt" class="org.jboss.soa.esb.actions.transformation.xslt.XsltAction"> <property name="templateFile" value="/smooks.xsl"/> </action> <action name="simple-transform" class="org.jboss.soa.esb.smooks.SmooksAction"> <property name="smooksConfig" value="/smooks-res.xml" /> </action> smooks.xsl: ------------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/|comment()|processing-instruction()"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:element name=" {local-name()}"> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{local-name()} "> <xsl:value-of select="."/> </xsl:attribute> </xsl:template> </xsl:stylesheet>
    • Release Notes Text:
      Hide
      https://issues.jboss.org/browse/SOA-3061

      If the input file for a Freemarker transformation contained a name-space declaration, users would encounter an freemarker.core.NonStringException. A fix has been applied so that these name-spaces are now stripped out, meaning users will no longer see the error.
      Show
      https://issues.jboss.org/browse/SOA-3061 If the input file for a Freemarker transformation contained a name-space declaration, users would encounter an freemarker.core.NonStringException. A fix has been applied so that these name-spaces are now stripped out, meaning users will no longer see the error.
    • Release Notes Docs Status:
      Documented as Resolved Issue

      Description

      Using an input file which contains a namespace declaration for a FreeMarker transformation leads to the following error:

      13:58:42,859 ERROR [runtime]
      Error on line 1, column 3 in orderLinesFrag.ftl
      Expecting a string, date or number here, Expression item.nachname is instead a freemarker.ext.dom.NodeListModel
      The problematic instruction:
      ----------
      ==> ${item.nachname} [on line 1, column 1 in orderLinesFrag.ftl]
      ----------

      Java backtrace for programmers:
      ----------
      freemarker.core.NonStringException: Error on line 1, column 3 in orderLinesFrag.ftl
      Expecting a string, date or number here, Expression item.nachname is instead a freemarker.ext.dom.NodeListModel
      at freemarker.core.Expression.getStringValue(Expression.java:126)
      at freemarker.core.Expression.getStringValue(Expression.java:93)
      at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
      at freemarker.core.Environment.visit(Environment.java:208)
      at freemarker.core.MixedContent.accept(MixedContent.java:92)
      at freemarker.core.Environment.visit(Environment.java:208)
      at freemarker.core.Environment.process(Environment.java:188)
      at freemarker.template.Template.process(Template.java:232)
      at org.milyn.templating.freemarker.FreeMarkerTemplateProcessor.applyTemplate(FreeMarkerTemplateProcessor.java:356)

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  tfennelly Tom Fennelly
                  Reporter:
                  mputz Martin Weiler
                  Writer:
                  David Le Sage
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: