This is the _very_simple_ demonstration project of
Suhai Bence for the course XML techniques for
e-commence.
The very simple content managment application on the right demonstrates
the use of:
- XML for data storage
- DOM for accessing elements, modifying content and
structure, and
serialization
Sample news are stored in an xml
file. Each news item is a child element of the "top" element, and
has a unique number stored in the "news_num" attribute. The one child
element of a new news item is the text element containing the actual
news.
Program logic was written in perl so I could also use the perl module
HTML::Template instead of XSL, which I am more familiar with. I used
the XML::DOM module for the DOM1 level access of the XML data, and also for
serialization. I wrote two perl cgi programs for the project:
setnews.pl:
- parses the XML file with XML::DOM
- traverses the DOM
- retrieves textual content from child nodes
- passes the textual content to HTML::Template to generate
HTML
layout (both normal news and editable news)
- receives modified or new text content and news number via
POST
from HTML forms
- receives deletion request with news number from a HTML link
- creates, deletes or modifies the corresponding child node
on the
DOM
- serializes the DOM upon changes
editnews.pl:
- parses the XML file with XML::DOM
- traverses the DOM to find child node with certain news
number
- retrieves textual content from the child node
- passes the textual content to HTML::Template to generate
HTML
forms (editable and new news items)
I could have merged the two perl programs into one, I only separated it
for convinience of debugging and testing. There are four HTML layouts
in this application:
Normal news:
- presents the news stored in the XML file formatted to look
readable
- presents and "Edit the news" link to go to the Editable
news
layout
Editable news:
- presents the news stored in the XML file formatted to look
readable with links to edit, delete, or add new individual news items
Editable news item:
- presents a form with the editable text of the corresponding
news
item
- presents a "set" button to submit the text via POST
New news item:
- presents an empty form for the new news item
- presents a "set" button to submit the text via POST
The actual working of the programs can be tested on the right. This
does not want to be a full-fledged content management system, only a
demonstration for the XML techniques
for e-commence course and a practice for me. Future plans:
|
|