[ https://issues.apache.org/jira/browse/FOR-1118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12636000#action_12636000 ]
Thorsten Scherler commented on FOR-1118: ---------------------------------------- Using the StAX implementation of the contract is different for junit in eclipse and within forrest. To test with forrest do the following: # preparation of forrest cd $FORREST_HOME/whiteboard svn switch https://svn.apache.org/repos/asf/forrest/branches/dispatcher_rewrite # create a new test seed cd $TEST_HOME forrest seed mv forrest.properties.dispatcher.properties forrest.properties cd src/documentation/ cp $FORREST_HOME/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/testing/org/apache/forrest/dispatcher/m2.contract.xml . cp $FORREST_HOME/whiteboard/plugins/org.apache.forrest.plugin.internal.dispatcher/src/testing/org/apache/forrest/dispatcher/master.structurer.xml . vi sitemap.xmap # add the following as child of map:components <map:transformers> <map:transformer name="dispatcher" src="org.apache.forrest.dispatcher.transformation.DispatcherTransformer"> <!--+ | If you want to use inline xml for contract properties be aware that setting | this properties to true will have negative influence on performance since | this feature needs to use DOM parsing! | | We strongly recommend to rewrite your contracts and structurer to use simple | string for the properties. | | The default is set to "false". +--> <!--<allowXml>true</allowXml>--> <!--+ | If you want to change the uri prefix of the contracts. | This may be interesting if you work with a contract repository rather then | with the ones from the themer plugin. | | The default is "cocoon://resolve.contract". +--> <!--<contractUriPrefix>cocoon://resolve.contract</contractUriPrefix>--> <!--+ | You can use either limited of full xpath support for the injection of contract | result data. We currently provide the basic support with a plain StAX implementation | and the enhanced support with AXIOM. | | The default is "basic". +--> <!--<xpathSupport>enhanced</xpathSupport>--> </map:transformer> </map:transformers> # and the following as child of map:pipeline <map:match pattern="test"> <map:generate src="master.structurer.xml"/> <map:transform type="dispatcher"> <map:parameter name="request" value="{0}" /> <map:parameter name="type" value="html" /> </map:transform> <map:serialize type="xml"/> </map:match> <map:match pattern="resolve.contract*"> <map:generate src="m2.contract.xml"/> <map:serialize type="xml"/> </map:match> As you see we are using the exact same files as in junit testing, however the result is not the same. If you now start your $TEXT_HOME with forrest run and request http://localhost:8888/test you will get an error. The command line will tell you: "SystemId Unknown; Line #4; Column #85; xsl:param is not allowed in this position in the stylesheet! [Fatal Error] :6:26: The prefix "forrest" for element "forrest:content" is not bound. SystemId Unknown; Line #6; Column #26; org.xml.sax.SAXParseException: The prefix "forrest" for element "forrest:content" is not bound." In junit all tests of both TestStructurer and TestContract are running fine and do not present the above error. I tracked down the problem to XSLContractHelper#processTemplate(XMLStreamReader reader). Here is an important difference between the junit and cocoon test. If you change in the above method the following + System.out.println(out.toString()); - log.debug(out.toString()); You will see for JUNIT: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="test-inline" select="'No parameter has been passed'" /> <xsl:param name="test-inline-xml" select="'No xml parameter has been passed'" /> <xsl:template match="/"> <forrest:content xmlns:forrest="http://apache.org/forrest/templates/2.0"> <forrest:part> Another test! $test-inline: <xsl:value-of select="$test-inline" /> $test-inline-xml: <xsl:copy-of select="$test-inline-xml" /> </forrest:part> <forrest:part xpath="/html/head"> <meta content="m2 - another test" name="Description" /> </forrest:part> </forrest:content> </xsl:template> </xsl:stylesheet> and in FORREST <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="test-inline" select="'No parameter has been passed'" /> <xsl:param name="test-inline-xml" select="'No xml parameter has been passed'" /> <xsl:template match="/"> <forrest:content> <forrest:part> Another test! $test-inline: <xsl:value-of select="$test-inline" /> $test-inline-xml: <xsl:copy-of select="$test-inline-xml" /> </forrest:part> <forrest:part xpath="/html/head"> <meta content="m2 - another test" name="Description" /> </forrest:part> </forrest:content> </xsl:template> </xsl:stylesheet> At the first look that seems to be the same but one important change is: <forrest:content xmlns:forrest="http://apache.org/forrest/templates/2.0"> in the cocooon env we are eating the xmlns. That is really weird since the code supposed to use the same time the same stax implementation (woodstox). > Dispatcher 1.0 - towards a stable version > ----------------------------------------- > > Key: FOR-1118 > URL: https://issues.apache.org/jira/browse/FOR-1118 > Project: Forrest > Issue Type: Improvement > Components: Plugin: internal.dispatcher > Reporter: Thorsten Scherler > > The current version of the dispatcher has some points for enhancement this > issue is to keep track of the changes. > The work is conducted in > https://svn.apache.org/repos/asf/forrest/branches/dispatcher_rewrite which is > based on trunk r700363 forrest/whiteboard. > The thread "Dispatcher 1.0 - towards a stable version" > http://markmail.org/message/nm6etnhg4nuhm2kl has pointed out: > - performance issues due to DOM usage in the current implementation and code > readability > --> 1.0 will provide two implementations pure StAX and AXIOM (OM StAX) > --> 1.0 will provide a cocoon transformer that can use either one of the > above implementation > - documentation -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.