XML Poll Page 1 - 3 Date: 2:30 PM 9/21/2002 By: M.Meijer XML Poll Table of contents 1. Introduction.......................................... 1 2. Files................................................. 1 3. Interfaces............................................ 2 4. Implementation considerations......................... 3 5. Example usage......................................... 3 1. Introduction The basic of this XML Poll is a way to save data to XML file and display this data from it. It's easely expandable, just add some more attributes to the XML elements. 2. Files The files are 3 asp files: "edit.asp, index.asp, include.asp", to edit and view the Poll, 1 transparent pixel ("trans_pix.gif") and the "poll.xml". poll.xml The "poll.xml" file holds the poll data. It starts with root element named "statement". The "value" attribute is holds the statement. The statement element can contain 1 or more "option" elements, "option" elements are the options a user has to vote. The "option" has 3 attributes. option element: 1. id, defines a unique id for the option. 2. hits, defines the amount of votes. 3. value, contains the option's value. include.asp In the "include.asp" file are some simple functions and the classes to interface with the xml file. edit.asp The "edit.asp" is a asp script to edit the "poll.xml file". It displays a form to edit the statement value and create, remove, and edit options. index.asp The "index.asp" displays a form to vote for a statement, diplays the current status. trans_pix.gif This is a 1x1 transparent GIF. XML Poll Page 2 - 3 3. Interfaces There are 2 classes to interface with the "poll.xml", oOption and oStatement. +---------------------------+ +----------------------------+ |oStatement | |oOption | +---------------------------+ +----------------------------+ |Value | |Value | |DataFile | |Id | |DataLoaded | |Hits | |Error | +----------------------------+ +---------------------------+ | | |LoadData() | +----------------------------+ |Edit() | |ChangeOption() | |CreatOption() | |RemoveOption() | |Options() | |IncreaseOption() | +---------------------------+ oStatement: -Value The current value of the statement. -DataFile The filename of the datafile, if loaded. -DataLoaded If a datafile is loaded correctly, this will be a boolean TRUE, else FALSE. -Error An error message if occured. -LoadData() The function to load a datafile, the file as argument, it will return a boolean TRUE if the file is successfully loaded else FALSE. -Edit To set the statement's value, the value is expected as argument. The function will return TRUE on success, else FALSE. -ChangeOption To change an "option", call this funtion with the "Option.id", and "Option.Value" as arguments. It will return a boolean TRUE on success, else FALSE. -CreateOption To create a new "option", call this function, the "Option.Value" is expected as argument. It will return a boolean TRUE on success, else FALSE. The "Option.Id" will be generated automatic inside the function. -RemoveOption To remove an "option", call this function and give it the "Option.Id" as argument. If the function succeeds it will return a boolean TRUE, else FALSE. -Options To get all "options" from the "statement". It will return an array type with "option" objects. -IncreaseOption To increase an option's hits call this function send the "Option.Id" as argument. It will return a boolean TRUE on success, else FALSE. XML Poll Page 3 - 3 oOption: -Value The value of the "option". -Id The id of the "option", this is the unique identifier for the "option". -Hits The amount of hits a specific "option" has. 3. Implementation considerations The examples show an implementation of a poll with the serverside scripting technologie ASP. Due the openess of XML and simplicity of the definition of the poll,it can be implemented on any system capable running RPC's. 5. Example usage To use the example files, just get any computer capable of running ASP and the MS XML4.0 processor. Edit the "include.asp" file's "STR_DATA_FILE" constant to define the absolute path to the XML datafile. XML Processor used: "Msxml2.DOMDocument.4.0" The script is tested on a WinXP PC running IIS5.1 &EOF