cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Delacretaz <>
Subject Re: Cforms basics
Date Wed, 04 Jan 2006 14:57:05 GMT
Le 4 janv. 06, à 14:46, Peter Flynn a écrit :

> ...Is there an example anywhere of a simple (1-variable) form which
> (a) writes its data to a new XML file and (b) inserts an element
> in an existing file?..

It's not 1-variable, but the XML binding sample (online at 
form2xml.flow) shows how to edit an XML file.

The flowscript is at src/blocks/forms/samples/flow/binding_example.js,  
the form2xml() function is what drives the editing process, and defines  
the input and output XML filenames (Sources actually, they can be more  
than filenames).

The corresponding sitemap excerpt (from samples/sitemap.xmap) is:

     <map:match pattern="form2xml.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="form2xml"/>
          <map:parameter name="definitionURI"  
          <map:parameter name="documentURI"  
          <map:parameter name="bindingURI"  

The form2simpleXML() variant does the same but without using bindings,  
the XML is edited as is, here's the sitemap excerpt:

     <map:match pattern="form2simpleXML.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="form2simpleXML"/>
          <map:parameter name="definitionURI"  
          <map:parameter name="documentURI"  

If you need to insert XML at various places in the edited files, the  
binding paths (in the binding definition file) should help, depending  
on how complex the XML manipulation is. For more complex merging of  
data, you can use processPipelineTo from flowscript, to process your  
XML data before writing it to disk.

Hope this helps,


View raw message