You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Steve Schwarz <sa...@hotmail.com> on 2003/07/13 17:34:25 UTC

Redirecting uploaded file content into existing pipelines?

Hi
I'm new to Cocoon and have read the two books; and the upload Wiki 
pages...but can't quite get my head around how to solve this problem (I'm 
using Cocoon 2.0 under 4.2 Tomcat)

I'd like to allow users to:
1. Upload an xml file
2. Validate it via XSD
3. Save it into my directory tree
4. process it using a number of transforms
5. serialize the transformed doc to the uploading client

So far I've got my config setup to handle uploads.
I (think I) can write an Action that validates the xml to my XSDschema via 
Xerces and returns an error page if it fails.
I can use the FileUploadAction from Cocoon Developer's Handbook to copy the 
file into my directory tree .
I also have a pipeline defined for generating/transforming/serializing valid 
XML files when they are requested directly by a client from within my 
directory tree.

What I can't figure out is how do I kick off my existing pipeline at the end 
of the two actions? This seems so basic but all the upload stuff I've seen 
doesn't re-SAX-ify the uploaded doc and process it (they all use parameters 
only of the request in the response to the client; not a transformation of 
the content of the actual file itself).

Is there a generator that I can apply right after the copy action that will 
SAX-ify the just copied file so I can use standard pipeline 
transforms/serializers?

Can I do something like use redirect after the actions and give it the 
directory/filename of where I moved the uploaded file in order to have the 
standard pipeline be applied? If someone has a pseudo pipeline for this I'd 
really appreciate it.

Any help is greatly appreciated.
Steve Schwarz

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Redirecting uploaded file content into existing pipelines?

Posted by Geoff Howard <co...@leverageweb.com>.
Unless I misunderstand you, you are frighteningly close to being done.

Steve Schwarz wrote:
...

> I'd like to allow users to:
> 1. Upload an xml file
> 2. Validate it via XSD
> 3. Save it into my directory tree
> 4. process it using a number of transforms
> 5. serialize the transformed doc to the uploading client
> 
> So far I've got my config setup to handle uploads.
> I (think I) can write an Action that validates the xml to my XSDschema 
> via Xerces and returns an error page if it fails.
> I can use the FileUploadAction from Cocoon Developer's Handbook to copy 
> the file into my directory tree .
> I also have a pipeline defined for generating/transforming/serializing 
> valid XML files when they are requested directly by a client from within 
> my directory tree.
> 
> What I can't figure out is how do I kick off my existing pipeline at the 
> end of the two actions? This seems so basic but all the upload stuff 
> I've seen doesn't re-SAX-ify the uploaded doc and process it (they all 
> use parameters only of the request in the response to the client; not a 
> transformation of the content of the actual file itself).

You have two paths you can take: you can generate from the uploaded file 
or you can generate from the FilePart object in the request.  A brand 
new generator to do that is sitting at bugzilla, but that won't help you
now, so go with the first.

If I've understood you, this should work:

<map:match ...>
   <map:act type="validate"> <!-- you'll need to write this AFAIK -->
     <map:act type="upload"> <!--save it to disk -->
	<map:generate type="file" src="wherever_you_saved_it"/>
	<map:transform .../>
	<map:serialize .../>
     </map:act>
	<!-- if upload fails -->
	<map:generate ..../>
	<map: ..... />
   </map:act>
	<!-- if validate fails -->
	...
</map:match>

You could also switch the order of the actions.  Let me know if that 
doesn't make sense.

If you want, you can have the upload action return the location of the
saved file on disk and use it in the src, like {foo} where the location
is put in the returned Map under the key "foo".

> Is there a generator that I can apply right after the copy action that 
> will SAX-ify the just copied file so I can use standard pipeline 
> transforms/serializers?

So, if you go with "SAX-ify"ing the uploaded file from disk, you just 
use the plain old file generator

> Can I do something like use redirect after the actions and give it the 
> directory/filename of where I moved the uploaded file in order to have 
> the standard pipeline be applied? If someone has a pseudo pipeline for 
> this I'd really appreciate it.

Sure, you could do that too but nested actions should do the trick.

> Any help is greatly appreciated.
> Steve Schwarz
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org