Looking into the source of the SWT, I can see that the source is written as soon as the </source:write> end tag has been received, which is the soonest that it is possible for it to be written.
Note, however, that any nodes in the XML stream that precede the <source> stuff, will already have been passed on to the next stage in the pipeline before the SWT can write the source. So your add2db transformer will be part way through its process before the SWT can write the source. This is just a part of how SAX based pipelining works.
Hope this makes sense.
Regards, Upayavira
Hugh Field-Richards wrote:
Hi
I have a pipeline whose main parts are
<map:transformer name="write-source" logger="sitemap.transformer.write-source" src="org.apache.cocoon.transformation.SourceWritingTransformer"/>
<map:match pattern="sendDoc.html"> <map:generate type="jxt" src="sendDoc-en.xml" /> <map:act type="auth-protect"> <map:parameter name="handler" value="adminHandler"/> <map:parameter name="application" value="adminApp"/>
<map:transform type="session" /> ... <map:transform type="write-source"/> <!-- Add to data base --> <map:transform type="add2DB"/> ... <map:transform type="encodeURL"/> <map:serialize type="html"/> </map:act> </map:match>
I have found that file that is created by the "write-source" does not exist for my add2DB transformer until the pipeline has run its course. I have put in the following in add2DB to force a delay to ensure that a simple delay is not the problem with SourceWritingTransformer:
long st = System.currentTimeMillis();
long t = st;
while ( !( new File( filePath ).exists() ) ) {
if ( t - st > 10000 ) {
throw new Exception( "File error: file '" + filePath + "' does not exist" );
}
t = System.currentTimeMillis();
}
The effect is to wait for 10 seconds before the pipeline is completed and the file appears in the file system with the above Exception being raised, which shows that the file is not created while the pipeline is still working. I am using BSD Unix on a Mac G4.
I guess the problem is that the file is not being flushed/closed within the SourceWritingTransformer. Any help here would be gratefully received.
TIA
Hugh F-R
Dr Hugh S. Field-Richards Principle Scientist QinetiQ, St Andrew's Road, Malvern, Worcs, WR14 3PS, UK Tel: ++1684 895075 Fax: ++1684 896113 Email: [EMAIL PROTECTED]
The views expressed above area are entirely those of the writer and do not represent the views, policy or understanding of any other person or official body.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]