Hello, I've just started to try to write my first Cocoon forms definition.
My application currently display an online calendar, which lists concert dates, rehersals, etc, for my local community choir. The definition fot the various events is held in an xml file with the following schema (I use REALX NG compact syntax to write the grammars, and then generate an xsd file using trang): # RELAX NG grammar for events.xml default namespace = "http://colina.demon.co.uk/onevoice/events" datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes" start = events events = element events {event*} event = element event {id, date, time-clause?, suppression, title, location} id = attribute id {xsd:ID} date = attribute date {xsd:date} time-clause = (time | closed-time) time = attribute time {short-time } closed-time = (time, finish) finish = attribute finish-at {short-time} short-time = xsd:string{ pattern = "[0-9]{2}:[0-9]{2}" } suppression = attribute suppress-recurring {xsd:boolean} title = element title {text} location = element location {text} At the moment, when a new event needs to be added, I edit the xml file directly, using emacs. I want other members of the choir to be able to edit events online, and CForms plus data binding seems ideal. Probably it should bind to a database, but I'm taking one step at a time. So I started by writing the binding definition. I took the XML Binding sample as a model (using just the repeater bit at the bottom of the page). I shall eventually want to do the date as an aggregate I guess, but for starters I'll just do it as a text field. My uncertainity comes with the time-clause in the grammar. This is optional (we often don't know what time a concert will start, when we first get a date for it). And the finishing time is optional too, but can only be present if the time attribute is present. So when I wrote the following, I paused for thought: <fb:on-insert-row> <!-- The insert-node element contains a piece of template XML to be inserted for new rows. Alternatively, you could also add a "src" attribute on the insert-node element pointing to an external source to retrieve the template from. --> <fb:insert-node> <!-- template inserted by the binding for new rows (mapping new nodes) --> <event id="" row-state="new" date="" time="" finish-at="" suppress-recurring=""> <title/><location/> </event> </fb:insert-node> </fb:on-insert-row> because I am not sure what is going to happen when the form is submitted. According to the validation criteria, the time attribute cannot be empty, but it can be missing. likewise finish-at attribute. Will form submission automatically infer this from the schema, and do the right thing? Or will I have to write some logic to handle this? CForms plus data binding is clearly very powerful, but writing the first form is a bit daunting. Thanks for any light you can shed. -- Colin Paul Adams Preston Lancashire --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
