On 12.05.2004 20:10, Christian Rosenberger wrote:

My sitemap would like this:

Generator => call flowscript => user doing updates => flowscript
calls transformer


I get XML from my backend java class. This xml data I want to use to
present a form with prefilled values. The user make changes and the
changed data should be inserted in a XML file which is sent by another


java class back to the backend. (same format, but other values).

To get data from backend I wrote a generator and to send it back to
backend I wrote a transformer.


To complicate IMO. Why not having a Data Transfer Object (a simple data
bean)? You can bind to that bean, load and save!

Why use a DTO if the woody binding can also bind to XML? Is there a alternative to woody binding? Want to use woody for validation.

Using the DTO does not mean to abstain from Woody.


No need for a generator and a transformer.


Because I need to send data as XML to my backend (XML database). The transformer sends the plain XML file filled in a XQuery to the backend. So transforming it into a DTO and back would be no good idea in my opinion. The data I got from backend is in XML format, so why transform it in a bean?

Ah, if you have already XML and need it in the backend too, then the conversion is not of sense of course. I thought you convert it in the generator/transformer from/to XML, e.g. via castor or another java/xml convertor.


Ok, than let's go on with it:

<map:match pattern="form">
  <!-- pass the control to flowscript -->
  <map:call function="form"/>
</map:match>

<map:match pattern="shwoForm">
  <!-- show the form to the user -->
  <map:generate src="formTemplate.xml"/>
  <map:transform type="woody"/>
  <map:transform type="woody-samples-styling.xsl"/>
  <map:trasnform type="i18n"/>
  <map:serialize type="html"/>
</map:match>

<map:match pattern="getData">
  <!-- flowscript calls this pipeline to get the data -->
  <map:generate type="yourGenerator"/>
  <map:serialize type="xml"/>
</map:match>

<map:match pattern="showResult">
<!-- after finishing you maybe want to present a result, below is just an example -->
<map:generate type="xsp" src="result.xsp"/>
<map:transform src="result2html.xsl"/>
<map:serialize type="html"/>
</map:match>


function form() {
    initializeForm(); //pseudo code
    //call pipeline to get the data
    var doc = cocoon.processPipelineToDOM("getData");
    //bind the data to the form
    form.load(doc);
    //show the user the form
    form.showForm("showForm");
    //save the data back to the XML
    form.save(doc);
    //get the object that will pass the data back to db or what ever
    var component =
    cocoon.createObject("your.component.FormerlyKnownAsTransformer");
    component.store(doc); //pseudo code
    cocoon.release(component);
    //at the end show a result
    cocoon.sendPage("showResult");
}

I hope this code is understandable. I kicked your transformer and made a pure component out of it. A transformer should in theory only transform documents and not interact with a backend. Also calling a pipeline that controls the storage sounds not that preferable. In the above the flowscript controller has the control. I would maybe also abstain from the generator and call the same component. If you need the generator and the transformer in other cases, you could also call that component. That's better reuse I think.

WDYT?

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to