cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christofer Dutz" <>
Subject [CFORMS] Alternate Suggestion-List generation
Date Fri, 25 Aug 2006 09:21:41 GMT


I would like to post an alternate way of generating suggestion lists. In our
current project we had the need of generating context-sensitive

Next to the context sensitivity, there were other things bothering us. While
debugging everything we had a look at what was actually happening: 


-          When the pipeline for generating the suggestion-list is called, 

o        the suggestion-list generator looks up the form and widget

o        the corresponding java-script block is executed on the widget:

*         Since the content of the suggestion-lists is the result of an
xquery, the first step was to do an xquery

*         The result of the xquery pipeline was loaded into a dom

*         that is walked through generating an array, which is returned to
the suggestion-list generator

o        that array is transformed to sax-events by the suggestion-list

o        this sax stream is then flattened back to plain old ASCII text in
the usual pipeline definition for suggestion lists


A conversion nightmare.


After quite some time of trying we found a way simplifying the way
suggestion-lists content is generated and as an addition we get the benefit
of being able to generate context-sensitive suggestion-lists very easily:


The pipeline for generating the content:

                  <!-- Pipeline for creating the suggestion list content.

                        the parameter "filter" contains the current content

                        the text field and "widget" the id of the currently

                        widget. These are used in the initial xslt
generating the

                        query. -->

                  <map:match pattern="_cocoon/forms/suggest">

                        <!-- generate an xml stream of the current form
model with

                        element name set to the id of a widget and it's
content to 

                        the value. I had to use this, because otherwise it
was not

                        possible to create suggestion-lists that are context

sensitive. -->

                        <map:generate type="forms-content"/>

                        <!-- prepare a database-query using the current form

This is where the real logic is set … using request-parameters

For individual xslts depending on the widget id are also 

possible -->

                        <map:transform type="xslt-saxon"

                        <!-- execute the query -->

                        <map:transform type="sql"/>

                        <!-- thransform the query results to a

                        a suggestion-list) -->

                        <map:transform type="xslt-saxon"

                        <!-- transform the selection-list to the primitive

                        the dojo component can operate on -->



                        <!-- send it back as text -->

                        <map:serialize type="text"/>




Widget definition (As you can see … there is no difference between a simple
text-field and a suggestion-list):

            <fd:field id="lad_plz" required="">


                  <fd:datatype base="string"/>


                        <fd:length max="6">

                             <fd:failmessage>Die PLZ darf nur 6 Buchstaben






Widget template:

            <ft:widget-label id="lad_land" type="suggest"/>


The logic for generating the suggestion-list content is now wrapped up in
the selection-lists/suggestion-list-query.xslt query.

It was much easier understanding suggestion-lists this way.


Just wanted to share my ideas and maybe get some hints for improvements.





[ c h r i s t o f e r   d u t z ]



univativ GmbH & Co. KG

Robert-Bosch-Str. 7, 64293 Darmstadt


fon: 0 61 51 / 66 717 - 21

fax: 0 61 51 / 66 717 - 29



Darmstadt, Stuttgart, Karlsruhe, Düsseldorf



View raw message