cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven D. Majewski" <sd...@virginia.edu>
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="http://apache.org/cocoon/source/1.0">
> <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  
accomplish,
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  
quite
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="../../ 
content/rc/{exception}.xsp">
                 	    <map:parameter name="user" value="{user}"/>
                     	<map:parameter name="filename"  
value="{filename}"/>
         	            <map:parameter name="date" value="{date}"/>
                         <map:parameter name="message"  
value="{message}"/>
             	      </map:generate>
                 	  <map:transform src="../../xslt/rc/rco- 
exception.xsl"/>
         	          <map:call resource="style-cms-page"/>
                 	</map:act>

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


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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message