Time for a progress update, although I don’t think I’m ready to release any code yet (if someone could donate CVS hosting that would be great - I don’t want to set up a “sourceforge”:http://sf.net or “Tigris”:/http://www.tigris.org project just for FormProcessor) as it’s still being hacked.
The biggest change is that I’ve moved to using XML_HTMLSax instead of PHP’s XML extension. This means that it’s roughtly 5 times slower (although I’ve not compared the two versions of my script together, only run the test that comes with XML_HTMLSax) but should hope with less well-formed XHTML, and won’t get stuck on @ @ any more.
There is also a rule parser now, and the rules are stored in XML files now. One point I’ve still not decided: _should the error messages be in the form’s file or in the XML file?_ Any formatting applied to the rules is presentation logic, but the rules are business logic… tell me what you think.
Below is a sample of the XML file. Currently I expect a separate file for each form, so no mechanism has been provided for extracting one specific form from a file. However, it should be easy enough to implement if required.
I’ve started on a front end now for generating the rulesets. And guess what? I can’t use FormProcessor in its current incarnation to fill in the fields. Why? Well, for ease of processing in the script, I’m giving my @input@ tags names like @rule[]@ or @entry[fieldname]@ so that I get arrays in PHP automatically generated. And FormProcessor doesn’t understand field names containing [] produce arrays. I guess I’m going to have to modify it at some stage to do so, but I think it would take quite a bit of work and probably slow down the script.
Nothing’s ever as straightforward as you think it should be ![]()
5 comments ↓
I would say that the error messages themselves are definitely presentation logic, and should thus be included in the XML. The fact that the email address was invalid is an application fact, but the way in which you tell the user this is presentational. For example, in an informal design you might want to say “Dude, bad address!”, while a more formal site would say “The email address you supplied was invalid”.
This leads to one of the biggest unsolved problems I had with FormProcessor - some inputs have a number of potential error messages (”You forgot to provide an email address” and “The email address was invalid”) for example. You need some kind of way of including these multiple error messages in the XML and specifying which message should be used for which type of error.
I seem to remember the original FormProcessor had “intelligent defaults” for situations where an error message wasn’t specified in the XML. I’d recommend keeping this, as it saves time for people who don’t care too much either way.
I would say that the error messages themselves are definitely presentation logic, and should thus be included in the XML. The fact that the email address was invalid is an application fact, but the way in which you tell the user this is presentational. For example, in an informal design you might want to say “Dude, bad address!”, while a more formal site would say “The email address you supplied was invalid”.
This leads to one of the biggest unsolved problems I had with FormProcessor - some inputs have a number of potential error messages (”You forgot to provide an email address” and “The email address was invalid”) for example. You need some kind of way of including these multiple error messages in the XML and specifying which message should be used for which type of error.
I seem to remember the original FormProcessor had “intelligent defaults” for situations where an error message wasn’t specified in the XML. I’d recommend keeping this, as it saves time for people who don’t care too much either way.
OK, please ignore both of the above double posted comments
I posted them before I’d finished reading your entry and missed the fact that the system uses two files now. I would say stick the error messages in the “rules” area rather than the XML file for the form, as the error messages that is used is governed by the rule that was broken.
Hey bro, if you need CVS hosting ping me, i have one box just sitting and doing nothing, i’m sure it would be happy to serve something
*Simon:* To clarify you comment posted on August 24, 2003 01:22, by XML are you referring to the XML file that holds the ruleset, or the X[_H_]TML file that holds the form?
*Dan:* I’ve replied by email - easier than logging into the admin to ping you
Leave a Comment