![]() |
![]() ![]() |
||
|
|||
What is CGI? |
CGI stands for the Common Gateway Interface and is currently at revision CGI/1.1 . It is "a standard for external gateway programs to interface with information servers such as HTTP servers:" more often than not, CGI is the method used when data, input at the client-side of a HTTP connection (e.g. in a form on a web-browser) is sent to the server-side (to be logged, or generate a web-page dynamically based on the data content).
|
||
The webserver takes any request including CGI data, and passes it onto the file requested: for anything to actually happen, the file must be an executable that can read the environment variables or standard-input that carry the CGI data, and then must be able to act on it. X-Tract and XML Script, in conjunction, can do both of these things easily. |
|||
Note that CGI forms need NOT return HTML, and neither need X-Tract. If your web-browser is configured to handle some other kind of file, then the HTTP Response that contains all of the results of the CGI handling can be in an arbitrary format. HTML is assumed for these examples, because all web-browsers can handle it (practically by definition!) and it's fairly trivial to force HTML into XML, making it easy to handle with XML Script. |
|||
The CGI object |
X-Tract handles CGI by creating a CGI object, at the root of the data tree. It also puts all of the CGI environment variables (along with the rest of the environment) in the ENV object. Thus the data tree, before anything else is put into it by the script, looks like:
|
||
Multipart form data |
X-Tract supports both the application/x-www-form-urlencoded and multipart/form-data CGI content types. When a file is encountered as part of multipart data the file is placed in the content of the CGI subobject. The "filename" and "Content-Type" attributes of the subobject are set appropriately. Thus a file entry in the data tree may look like:
|
||
Microsoft Internet Information Server does not handle multipart/form-data correctly and you may experience problems attempting to use X-Tract with IIS in this capacity. |
|||
Accessing CGI data |
Accessing CGI data in XML Script is simple: use interpolations within \# characters as explained in previous tutorials on interpolations and the data tree.
|
||
Next... | |||
XML Script homepage | Documentation home | XML Script docs | Command list | Function list | X-Tract docs X-Stream, X-Tract and XML Script are trade marks of DecisionSoft Limited© Copyright 1998-2000 DecisionSoft Limited |