cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mac Schwarz <>
Subject Re: XSP form processing
Date Mon, 21 Aug 2000 12:45:51 GMT
Ricardo Rocha wrote:
> Mac Schwarz wrote:
> > <gaptext>
> > In this sentence a <gab id="1">word</gap> ist missing. Complete these
> > two <gap id="2>sentences</gap> with the correct words.</gaptext>
> XSLT may be enough (provided I really got it):
> <xsl:template match="gaptext">
>   <form action="gaptext.xml" method="post">
>     <xsl:apply-templates/>
>   </form>
> </xsl:template>
> <xsl:template match="gap">
>   <input name="guess" type="text" size="{string-length(.)}"/>
>   <input name="word" type="hidden" value="{string(.)}"/>
> </xsl:template>
> These templates should generate something like:
> <form action="gaptext.xml" method="post">
>   In this sentence a
>      <input name="word" type="hidden" value="word"/>
>      <input name="guess" type="text" size="4"/>
>   ist missing. Complete these two
>      <input name="word" type="hidden" value="sentences"/>
>      <input name="guess" type="text" size="9"/>
>   with the correct words.
> </form>
> so that "gaptext.xml" (presumably an XSP page) can process
> the request examining the multivalued parameters "word" and
> "guess":
> . . .
> <xsp:page xmlns:request="">
>   <page>
>     <xsp:logic>
>       String[] words = request.getParameterValues("word");
>       String[] guesses = request.getParameterValues("guess");
>       int i;
>       for (i = 0; i < words.length; i++) {
>         if (!words[i].equals(guesses[i])) {
>           break;
>         }
>       }
>       if (i == words.length) {
>         <p>Hey! You're a genius!!</p>
>       } else {
>         <p>Try again... asshole!</p>
>       }
>     </xsp:logic>
>   </page>
> </xsp:page>
> . . .

Thanks, but no one would be an asshole and all would be geniuses :-)
Just a look in the pagesource for the hidden input fields.

I'd like to have a simple xml file like

<?xml version="1.0" ?>

<?cocoon-process type="xslt"?>

<?xml-stylesheet href="xsp.xsl" type="text/xsl"?>


In diesem Satz fehlt ein <gap id="1">Wort</gap>.
In diesem Satz fehlt ein <gap id="2">anderes</gap> Wort.

The exercises will be written by our teachers so I don't want any logic
in the file (besides of the logic of the execises if there's any).

And I want to process this file with an xsl stylesheet (and later with a
xsp stylesheet and the a xsl stylesheet to seperate logic and style like
the xsp page/page-xsp/page-html example for cocoon). The stylesheet
should create a <form action="gaptext.xml" method="POST"><input
type="text" name="{@id}/> tagset for the gaps distinguished by the gap

If the page is called the first time I've got no parameter values and
the form with empty textfields is generated. If the form is submittet my
stylesheet should extract the request parameters (the gap id) and it's
values (the text typed by the student) and compare it with the text
inside the gap tags with the corresponding gap id. If they match the
text field of the form should be filled with the correct text. If they
don't match the text field should be emty for the next try. If all words
were filled correctly in the gap fields the next exercise should be

This may sound complicated it's a task you have often. If you want to
sign up to a new service on the internet you have to fill a form with
the username, desired password, your name and maybe a email adress. If
the username is already taken you will get the same form with your name
and email adress in the text fields of the form but an empty username
field. If all fields are filled correctly you'll get a 'thank you' page.

Maybe I should go for a walk in the park to flee the sound of
jackhammers in the next room and hopefully getting a idea how to achive


Mac Schwarz / AERIA Projekt / Inst. f. Klassische Archaeologie
e-mail:  / Tel.: 09131-85-24791
 FAU Erlangen-Nuernberg   /   Kochstr.4   /   91054 Erlangen

View raw message