Changed XML (post xslt) JavaBinding not working

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Changed XML (post xslt) JavaBinding not working

Lalit
Hi All,

I am trying to do a simple javabinding on an xml which first gets changed (an element is added ) using xslt. In JavaResult post filter, the element which got added does not reflect, which means in the final HashMap element2 does not come though element1 comes.

Following are the source-xml,xslt, smooks-config and code fragment I have used. Please suggest if I should be doing something differently.


InputXML
  <source>
        <list>
            <element id="1">10</element>
        </list>
    </source>


XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                version="1.0">
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>
<xsl:template match="list">
  <list>
     <xsl:apply-templates select="@* | *"/>
     <element1 id="2">20</element1> 
  </list>
</xsl:template>
</xsl:stylesheet>


smooks-config
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
                                          xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.4.xsd" 
                      xmlns:xsl="http://www.milyn.org/xsd/smooks/xsl-1.1.xsd">

    <xsl:xsl applyOnElement="#document">
        <xsl:template>/example/BasicXslTransform.xsl</xsl:template>
    </xsl:xsl>

        <jb:bean beanId="VoltErrorMap" class="java.util.HashMap" createOnElement="list" retain="true">
       
         <jb:value property="element" data="element"/>
         <jb:value property="element1" data="element1"/>
       
</jb:bean> 
       
</smooks-resource-list>



Source

        // Instantiate Smooks with the config...
        Smooks smooks = new Smooks("smooks-config.xml");

        try {
             // Create an exec context - no profiles....
            ExecutionContext executionContext = smooks.createExecutionContext();
                        JavaResult result = new JavaResult();

            // Configure the execution context to generate a report...
            executionContext.setEventListener(new HtmlReportGenerator("target/report/report.html"));

                        smooks.filterSource(executionContext, new StreamSource(new ByteArrayInputStream(messageIn)), result);
}