cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Nuetzel - inglobo" <>
Subject Re: [RT] forms
Date Thu, 19 Jul 2001 19:17:27 GMT

>> I've implemented something similar:
>> My form descriptor is similar to the XForms WD. I've made some
>> simplifications and some enhancements to allow simple processing and
>> validation definitions.
>> example form control:
>>     <textbox ref="person/user-id">
>>         <caption>User ID</caption>
>>         <validate type="null">User ID must be specified.</validate>
>>         <validate type="string" minlen="5" maxlen="20">The User ID must
>> have 5 to 20 characters</validate>
>>         <validate type="unique">The User ID is already used. Please
>> an other.</validate>
>>     </textbox>

thanks ... but not Xform conform - AFAIK XForm doesn't specify validation
messages or error codes until now. Perhaps something similar will be
integrated in future versions of the WD.

>> For presentation the form descriptor is transformed by a special XSLT
>> sheet. I make heavy use of the xalan:evaluate() extension to fill the
>> instance data in the form (dont know a XSLT conform solution to resolve
>> ref attributes). Then the evaluated form page is transformed to HTML
>> and sent to the client. I use the values of the ref attributes as HTML
>> control names.
>Why do you use xalan:evaluate() to fill in the data?

I need it to evaluate the XPath values of the ref attributes of the form

        <textbox ref="person/firstname">
            <caption>First Name</caption>

to transform this to HTML the following stylesheet may be used:
<xsl:variable name="instance" select="/form-descriptor/instance"/>

<xsl:template match="textfield">
     <xsl:value-of select="caption"/>
     <input type="text" value="{xalan:evaluate(concat('$instance/',

AFAIK there is no possible solution with pure XSLT. An alternative would be
a Transformer which fills in the data.
I think there is also some kind of intermediate format necessary which
represents the evaluated form. I think adding the evaluated values as
elements to the form controls like you proposed in your last mail is a nice
solution. So you get a simple and straight XML document which may be easily
transformed to special presentations by user stylesheets.

>> The response from the client (ServletRequest) is evaluated by an Action.
>> the first request of the form an XMLFragment (Node, DocumentFragment) is
>> created from the default instance data in the form descriptor or the
>> referenced XML data (using XLink). The request values from the HTML form
>> are validated and written to the DOM Node. The DOM Node is saved as
>> attribute or in the session if needed over more requests (multipage
>> If the submitted form data is not valid according to the information in
>> form descriptor the Action redirects the user request to the form
>> presentation again. There I use an extented TraxTransformer to pass the
>> updated DOM Node (instance data) and the validation result to the XSLT
>> sheet as parameters (as XPath node-set).
>Hmm... we should get around without redirects...

You are right. Actions and maybe Selectors should do it.

>> Currently I operate only on XML files - no database or business objects
>> involved.
>> My multipage solution is very simple. I define a total number of pages
>> my form descriptor and the same amount of form elements with
>> page attributes:
>> <form-descriptor pages="3">
>>     <instance/>
>>     <form page="1"/>
>>     <form page="2"/>
>>     <form page="3"/>
>> </form-descriptor>
>> The disadvantage of this solution is that only multi page forms with a
>> sequential process can be declared. But I dont need other ;-)
>> I would like to donate my stuff. But I must admit its a very raw hack
>> needs lots of refactoring. And I've only implemented the things I really
>> needed for my project (of course ;).
>I think that's great!
>I'm really optimistic to have a standard sollution soon!

Thank you.
I think this could turn out in a very sophisticated project.


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

View raw message