cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven D. Majewski" <>
Subject Re: Create New File
Date Fri, 12 Jan 2007 16:59:44 GMT

On Jan 11, 2007, at 4:18 PM, BMur wrote:

> Hello, I'm using Cocoon version 2.1.7:
> I have an instance of Lenya, which uses Cocoon, and I beleive this  
> question
> is related to Cocoon more than Lenya.
> I would like to create a new file within the filesystem on-the- 
> fly.  If
> possible I would like to do this in an xmap file (usecase.xmap).   
> I'd like
> to pass the xmap file some variables, and create a new xml file  
> based on
> those variables.  For instance:
> <source:write create="true"
> xmlns:source="">
> <source:source>MyTestfileName.xml</source:source>
> <source:fragment>"Value of passed variable"</source:fragment>
> </source:write>
> I've tried various methods of creating the file using source:write  
> in the
> xmap, however nothing has worked thus far.  I'd paste my errors here,
> however I receive different errors depending on the different  
> attempts I've
> made.
> Can anyone help, or provide an alternative for creating files on  
> the fly?

It's not really clear from your message either what you're trying to  
or how you're trying to do it currently.  ( For example: I'm not  
quite sure what
you could mean by "pass the xmap file some variables" -- this doesn't  
parse for me. Are you trying to modify an uploaded file, or are you  
trying to
generate a file from a template with variables ? Sourcewriter is  
probably not
the best tool for the latter. )

You're not trying to put the <source:*> tags in the xmap file, are you ?

If you look at the fragment in lenya's usecase.xmap file where the  
source writer is called,
what's happening is that a file is being sent via HTTP POST, the  
stream generator is
being called to start processing that file thru the xml pipeline, and  
and xslt transform is
done ( using xslt/authoring/edit/addSourceTags.xsl ) to wrap the  
<source:write> and other
source:tags around the content. ( That's where the source:tags  
belong, not in the sitemap. )

           <map:match pattern="xml" type="step">
             <map:match pattern="*/*/**.html">
               <map:select type="request-method">
                 <map:when test="POST"> <!-- Save -->

                   <!-- test if the document is checked out -->
         	        <map:act type="reserved-checkout-test">
             	      <map:generate type="serverpages" src="../../ 
                 	    <map:parameter name="user" value="{user}"/>
                     	<map:parameter name="filename"  
         	            <map:parameter name="date" value="{date}"/>
                         <map:parameter name="message"  
                 	  <map:transform src="../../xslt/rc/rco- 
         	          <map:call resource="style-cms-page"/>

                   <map:generate type="stream"/>
                   <map:transform src="xslt/authoring/edit/ 
                     <map:parameter name="source" value="pubs/{1}/ 
                     <!--<map:parameter name="source" value="pubs/{1}/ 
                   <map:transform type="write-source">
                     <map:parameter name="serializer" value="xml"/>
		  <map:act type="workflow">
		    <map:parameter name="area" value="{page-envelope:area}"/>
		    <map:parameter name="document-id" value="{page- 
		    <map:parameter name="language" value="{page-envelope:document- 
		    <map:parameter name="event" value="edit"/>
                   <map:serialize type="xml"/>
                 <map:otherwise> <!-- GET: Open -->
                   <map:generate src="pubs/{1}/content/{2}/{page- 
                   <map:serialize type="xml"/>

These are quite distinct steps in cocoon.
If you want to generate content from a template using parameters, jx  
transformer/generator or xslt
might be the tool for that step.

-- Steve Majewski / UVA Alderman Library

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message