You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter Flynn <pf...@ucc.ie> on 2006/01/04 14:46:59 UTC

Cforms basics

I'm just starting to look at using Cforms and there are a few things
that I don't find obvious (and I'm an XML document-head, not a Java 
programmer :-)

I think I've grokked definitions and templates, and the flowscript
and pipelines seem do-able.

The application will need to gather new data from a user. Some of the
values will need to be written to new XML instances on the server;
other values will need to update existing XML files on the server, 
either by changing existing element data content or attributes within 
the file, or by inserting a new element with several subelements at 
the end of the file (ie immediately before the end-tag of the root 
element.

The simple XML binding seems to be the obvious one, but the section
labelled "Usage" http://cocoon.apache.org/2.1/userdocs/xmlbinding.html
is completely opaque to me and I can't find an example to refer to.

The standard binding makes more sense to me, as it's all XML, but I
don't see where you specify *what* files to output the data to.

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?

///Peter



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


Re: Cforms basics

Posted by Christian Bindeballe <yo...@gmx.net>.
Peter Flynn schrieb:
 > 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?
 >
 > ///Peter
 >

that is wonderfully put, exactly what I'd need, too.
any ideas, anyone?

christian

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


Re: Cforms basics

Posted by Bertrand Delacretaz <bd...@apache.org>.
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  
http://cocoon.zones.apache.org/demos/21branch/samples/blocks/forms/ 
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"  
value="forms/form2_model.xml"/>
          <map:parameter name="documentURI"  
value="forms/form2_data.xml"/>
          <map:parameter name="bindingURI"  
value="forms/form2_bind_xml.xml"/>
        </map:call>
      </map:match>

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"  
value="forms/form2_model.xml"/>
          <map:parameter name="documentURI"  
value="forms/form2_simple_data.xml"/>
        </map:call>
      </map:match>

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,

-Bertrand