starter: Displaying a process start form

Previous: checkin: Declaring a new 'canonical' version ] [ Top: The procdef manager ] [ Next: datasheet: Generating a blank datasheet ]

The start form generator is pretty straightforward. Given a procdef identifier, we load the procdef item file first and find the current version of the definition. Then we load that definition and get some pertinent information, mostly the data items it needs to get started, but also a title. We return our data on stdout in line-based format; the first line is the title of the process, the second is the current version, and each subsequent line is a data item, formatted as a table row.

In retrospect, this functionality belongs in the wftk core engine rather than here, but it's here now and I can still see some merit it doing things this way around.
 
See Loading an item file
sprintf (sbuf, "%s%s_%s.xml", PROCESS_DEFINITION_REPOSITORY, xml_attrval (query, "item"), xml_attrval (item, "ver"));
file = fopen (sbuf, "r");
if (!file) {
   sprintf (sbuf, "Unable to open procdef version file %s.\n", sbuf);
   complain();
}

version = xml_read (file);
fclose (file);

if (!version) {
   sprintf (sbuf, "Corrupt version file %s.\n", sbuf);
   complain();
}

if (strcmp (xml_attrval (version, "name"), "")) {
   printf ("%s\n", xml_attrval (version, "name"));
} else {
   printf ("%s\n", argv[2]);
}
printf ("%s\n", xml_attrval (item, "ver"));

xml = xml_firstelem (version);
while (xml) {
   if (!strcmp (xml->name, "data")) {
      See Handling formatting of data items
   } else if (!strcmp (xml->name, "sequence")) {
      break;
   } else if (!strcmp (xml->name, "parallel")) {
      break;
   } else if (!strcmp (xml->name, "task")) {
      break;
   }

   xml = xml_nextelem (xml);
}


Handling formatting of data items
A starter data item is one which we encounter before encountering some action (really before encountering anything that can block.) When we find one, we need to emit a line of HTML table which will format it. How we do that depends on its type.
 
printf ("<tr><td>%s</td>\n", xml_attrval (xml, "name"));
printf ("<td>");
if (!strcmp (xml_attrval (xml, "type"), "text")) {
   printf ("<textarea name=\"%s\" rows=5 cols=30>", xml_attrval (xml, "name"));
   xml_writecontent (stdout, xml);
   printf ("</textarea>\n");
} else {
   printf ("<input name=\"%s\" value=\"", xml_attrval (xml, "name"));
   xml_writecontent (stdout, xml);
   printf ("\">\n");
}
printf ("</td></tr>\n");
Previous: checkin: Declaring a new 'canonical' version ] [ Top: lpml alpha ] [ Next: datasheet: Generating a blank datasheet ]


This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.