[ proj5b ] Manipulation of an XML file via an HTML form (with PHP)

Un project Staf-18 (promotion EVA 1998/2000).

Début du projet:31/ 05/ 1999.
Fin du projet:06/ 07/ 1999.
Estimation du travail:34 jours
Avancement:100%.

1. Participants

Participant

Prénom et Nom:Paraskevi (Vivian) - Synteta
LDAP:uid=paraskev,ou=staf,o=tecfa.unige.ch
Email:synteta8@etu.unige.ch
URLs:home - work

2. Specification

But principal: Create/Edit/Load "project.xml"

Via a form through a web page of TECFA campus to be able to edit a specific xml file or create a new one according to the reffering DTD.

More specificaly, create an online form through which a STAF student will be able to edit his own xml file for the management of project staf18 by just filling the fields of the form.

Like that, the student doesn't have to bother using specific software and, the professor can be assured (or at least control) that each student has filled in the right way his project's file. So, I would say that it makes things easier and less time-consuming.

In the beginning it sounded really nice, the worst came later :)

Objectifs et/ou questions de recherche (objectives)

ButCreation/Loading/Editing
détails:

Construct an ergonomic HTML form, in a way that it's fields will be able to describe completely an xml file based on the project.dtd (DTD).

Facilitate creation/editing on-line of the proj*.xml file. That is, filling the spaces between the xml tags with the data provided through the HTML form, creating a well-formed XML file and also validated according to it's DTD.

Ability to visualize an XML file (among the ones created with the same application) by loading it's data on the same form. Like that, it will be possible to edit again the file and make any corrections/addings etc.

The names given to the files created will have the format "uid".xml, that is the LDAP-uid that corresponds to the author of each file.

Auto Critique:Fianlly, I gave the opportunity to the user to choose his own name (that means that I should check whether a file exists already with the same name, which I don't check :) I have to be honest, no?

Enseignant:
14/ 06/ 1999

ok

But this is IMHO a second priority (since it can be done quite easily with and XSL servlet

Etudiant:
21/ 6/ 1999

Misunderstood

Now that I joined the workpackages Creation/Editing/Loading I hope that it's more clear what I mean by visualization. I mean to load the file again to the same form, otherwise of course the XSL servlet will do the work :)

ButStudent authentication
détails:Based on the student's login name, and being authenticated via LDAP server with the given password, personal data will be filled in automatically and modification of a file will be possible only for the author/owner of the file (the rest will be able only to visualize it through the XSL servlet) and the super user that will be the professor.
Auto Critique:I didn't implement this one except from the login through LDAP just for practical reasons...

Enseignant:
14/ 06/ 1999

ok

Just to make sure: The password is NOT part of the XML data, just the LDAP id. Your php application will simply ask the students to supply a password and ask the LDAP server if it's ok.

Etudiant:
21/ 6/ 1999

Ok, got it!

Ok, as you can see from my latest staf14 I understood quite well now :) how LDAP works.

Commentaire de l'enseignant sur les objectifs


Enseignant:
07/ 06/ 1999

Contexte

For the first year project staf18 of STAF students at TECFA. It will be reached from a web page through Tecfa Virtual Campus. This, I hope, that will facilitate the manipulation of their project management file.

Workpackages

WP Gathering of ressources [ ]
Planning: Start: 31/ 05/ 1999. End: 01/ 06/ 1999. Estimation du travail: 2 jours. Avancement: 100%.
A faire:Books for XML, relevant sites, guidelines from Daniel, PHP manual, LDAP info
Infos diverses:Of course, I will continue to gather resources during the whole project...
Auto Critique:That was the easy part, at least for all apart from XML...
WP Study the schemas of DTD [ ]
Planning: Start: 2/ 06/ 1999. End: 4/ 06/ 1999. Estimation du travail: 3 jours. Avancement: 100%.
A faire:Read relevant books and study examples but more specificaly to study the project.dtd and realize which are the problems that I have to focus my attention.
Infos diverses:I wish I could have found more books...
Auto Critique:In fact, at this level I didn't realize which were the problems exactly ...
WP PHP code for edition [ ]
Planning: Start: 10/ 06/ 1999. End: 04/ 07/ 1999. Estimation du travail: 10 jours. Avancement: 100%.
A faire:Write the PHP code to create and edit the xml file via an HTML form. My first attempt was to use the simplest form that could be, in order to work on the code and in the end to work on the final form.
Infos diverses:I decided in the end to work in parallel the workpackages that start from this one, up to the next 2 because they are linked together and affect each other.
Auto Critique:From this very moment started all my troubles...
Commentaires de l'enseignant et répliques

Enseignant:
07/ 06/ 1999

WP Ergonomic form [ ]
Planning: Start: 09/ 06/ 1999. End: 05/ 07/ 1999. Estimation du travail: 03 jours. Avancement: 100%.
A faire:Try to find the best way to present the HTML form. This means that I will have to create a form with an interface that will be user-friendly and ergonomic but also to deal with several problems that exist (see problems).
Infos diverses:
Auto Critique:The fields that the form has are awfully a lot, and it was a nightmare dealing with them and try not to forget any (which I didn't succeed in the end - I think I forgot "misc-info" :)
Commentaires de l'enseignant et répliques

Enseignant:
07/ 06/ 1999

WP PHP code to load an xml file inside the form [ ]
Planning: Start: 10/ 06/ 1999. End: 26/ 06/ 1999. Estimation du travail: 10 jours. Avancement: 100%.
A faire:Write the PHP code in order to be able through the web page to load an already created file with this form and edit it. That means parsing the xml file with the PHP parser and show the non-markup data at the according fields of the form.
Infos diverses:
Auto Critique:Thanks to the path (of tags parsed) I create, I can find the depth of each non-markup data and get distinguish every workpackage for example.
Commentaires de l'enseignant et répliques

Enseignant:
14/ 06/ 1999

Not XSL

No, you have to do it "by hand" with the XML parser OR use just the XSL translator servlet I installed. See the examples in the PHP example directory for a PHP stream-based parsing solution.

Etudiant:
21/ 6/ 1999

Ok

I have also cleared this thing out so far, so consider it as a stupid question I have just made :)
WP Student authentication [ ]
Planning: Start: 18/ 06/ 1999. End: 03/ 07/ 1999. Estimation du travail: 2 jours. Avancement: 100%.
A faire:Use the LDAP server to authenticate the login (name+password) of the user in order to proceed to the edition of a file. That means that edition will be possible only for the author/owner of each file and of course the professor to enter his comments that appear immediately after every possible field ready to be filled :)
Infos diverses:
Auto Critique:That was an easy part of the project which I didn't exactly implemented thoroughly as I explain elsewhere.
Commentaires de l'enseignant et répliques

Enseignant:
07/ 06/ 1999

WP Testing - Uploading to TECFA server - Evaluation [ ]
Planning: Start: 03/ 07/ 1999. End: 06/ 07/ 1999. Estimation du travail: 3 jours. Avancement: 100%.
A faire:Test everything if it works the way I was thinking about it.
Infos diverses:Of course, I will test every phase (workpackage) while I will work on it separately also...
Auto Critique:Although it was a dirty job, I knew I had to do it in order my work to be complete and now I am proud to say that works quite well...
WP Report [ ]
Planning: Start: 06/ 07/ 1999. End: 07/ 07/ 1999. Estimation du travail: 1 jours. Avancement: 100%.
A faire:Make the last corrections possible and fill in the after-thoughts. I will try to write the report immediately as I finish while I will have still fresh everything on my mind...
Infos diverses:
Auto Critique:This seemed in the end to be the most difficult part, after all stress I have been through but I took a deep breath and Tada! here it is...

Enseignant:
14/ 06/ 1999

OK

but concentrate on the editing WP. This is the only really difficult thing :)
Etudiant:
21/ 6/ 1999

Ok

Ok, I agree that editing is quite difficult or maybe quite boring :) considering the amount of data that each xml file will have to deal with... Audit:okThere is some difficulty ahead 23/ 06/ 1999Finding a general solution for editing XML contents via an HTML form is not easy. In particular, adding new elements is probably "casse tête". I gave modification (not adding elements) of elements a try. It's a general solution and you can look at it: http://tecfa2.unige.ch/staf/staf-e/staf18/edit-tree.php . In any case you got to finish your project. If you get too much stuck, get in touch and negociate

Récits (stories)

Editing project.xml file

A student of TECFA in order to fill in the project.xml file for STAF18 he can go to Tecfa Campus and fill in a form with all the data needed. When he will submit the form immediately it will be created the corresponding xml file.

The fields that refer to his personal data like name, email, etc will be automatically filled in to correspond to his login name for the campus.

Once his file has been created, he will be able to load it again from the same page inside campus and modify it or edit it again. But, only the owner of each file will be able to edit it, the rest students will be able only to load a file and see it's content (probably through the XSL servlet) in order to avoid the deletion of a file by mistake by another student.


Enseignant:
07/ 06/ 1999

Loading project.xml files

Every student will be able to go to a page inside campus and choose from a list of all the proj*.xml files created for staf18. When he chooses a file from the list he will be able to see it's content and get ideas. Later, he can create his own file or modify his existing file.

Editing proj*.xml file

The professor of staf18 will be able to go and check the proceeding of all the proj*.xml files and edit his comments to each one. Here, we could add a different view for the professor that could be an overview of all the projects by a specific field etc.

Ressources niveau spécifications

ItemOnline resources
Précisions:

Daniel Schneider's resources, existing parsers on the web, PHP similar examples from TECFA server, LDAP server.

and so many more ...
Auto Critique:

Enseignant:
/ 06/ 1999

Choses promises (deliverables)

ItemA PHP code that works
Précisions:I will try to write a code that works and gives at least the minimum of my expectations. That is, I will create a quite ergonomic form and write the code for creation/editing the xml file. Student authentication seems trivial now I found out how it can be done, so I take it for granted :) But I cannot guarantee that I will create the complete form for all the fields needed because the proj*.xml file is quite huge :)
Auto Critique:In the end, I manage to provide almost all the possible fields... ouf!

Enseignant:
/ 06/ 1999

Problèmes avec la spécification


Problème: open
Mod: / 06/ 1999
HTML form
Précisions:

I have to decide how am I going to make the form, either everything at the same page (problem: huge form), either split to many pages (problem: user lost inside navigation). But if I decide to make everything at the same page I have an extra problem with fields that might be more than one. For example, if the user wants to put more "GOALS" than one I HAVE to provide extra windows for these fields, which means having many smaller forms. Can you think of a better solution?

Solution:
Auto Critique:The problem is solved, frames!

Problème: open
Mod: / 06/ 1999
LDAP server
Précisions:

How we can get the personal data for a student through LDAP? For the moment I got only the LDAP dn.

Solution:
Auto Critique:This is still an open question :)

Les commentaires de l'enseignant sur la spécification


Enseignant:
/ 06/ 1999


Enseignant:
07/ 06/ 1999


Enseignant:
07/ 06/ 1999

Problèmes avec le projet (niveau très général)


Problème: open
Mod: / 06/ 1999
Technical
Précisions:I have still emacs without validation, I am still waiting for the XML books I ordered and I still have the same old computer to work :)
Solution:Have to live without :))) and accept it!
Auto Critique:

Ressources générales

Item
Précisions:
Auto Critique:

3. Résultats

RésultatThe application (Le dispositif)
Précisions:This application is formed from all of the following:
  1. welcome.html, the welcome page to the application for the authentication by login to LDAP server
  2. ldap.php, that dynamically creates a web page through which a student can create a new file by giving the name of the file in a form field, and generates a sorted list of the xml files available for editing ...
  3. frames.php, the main page of the project that has 2 frames, one with the menu of all the sections available of the project management and links to staf18 and to the welcome page and the other one with the first section of the project management with the general info
  4. parsexml.php, the procedure for parsing an xml file respecting the according DTD. Parsing has been made with the use of a path being created from the xml tags each time in order to give the depth of data inside the xml file.
  5. writexml.php, the procedure to write the xml file.
  6. variables.php, the file that includes all the main variables in order to diminish the size of the paths I use for parsing
  7. files/, the directory where there are the xml files that are available for parsing and also where the new files will be stored that will be created. Here, I have to note down that in order to work, I had to change the permission to the xml files in order someone to be able to write and edit them, and also to change the permission of the directory so as to allow someone to create a new file in it...
  8. new.aaa, empty xml file that includes all the sections of one time respecting the DTD. Every time that a student wants to create a new xml file, I copy this file with the name that the student has given to the initial form after the LDAP authentication.
  9. Couples of programs like: goals.php + Wgoals.php, where the first file parses the data from the file asked and the second writes the new data by creating a new xml file from the very beginning... So these coupled files go on like that: ( form.php + Wform.php ), ( Mgoal.php + WMgoal.php ), ( delivs.php + Wdelivs.php ) etc.....
Auto Critique:

We are talking for a source code of approximately 4000 lines (!!!) 99% error-free (I spent quite some time debugging :) and testing (of course, a professional programmer might have done it better and may be smaller in certain parts, but no one is perfect :)))

I used a "homemade" server made by Vlachoudis Vassilis (my husband :) that made my life easier working and testing everything at home before uploading everything to TECFA server for the final debugging, corrections and testing LDAP login...

I didn't implement the part to parse the personal data of the members of the group for each project from LDAP server basically for 2 funny reasons: first, I didn't know the names of the variables that LDAP uses for such data and second, I asked Daniel, but I didn't get an exact answer (probably I wasn't clear enough) and I didn't get in trouble asking him again (I was really tired to go on with this and I just let this go :)) So, I don't check whether someone is the owner of a file in order to permit writing on it (thing that makes the authentication useless :))) for the moment... Both of the above are really easy to implement but I don't know in a way I didn't have the courage to finish them also... :)

Things that are missing although I would liked to have included also are: a nicer interface (nicer buttons, colours, tables, etc), well-formed messages (to inform the user for every action), reload after submission(automaticaly of every page sumbitted in order to see how it looks like the xml file with new data) and some more that I forget right now :)

I don't use anymore the tags PARA and LIST-ITEM because if a student uses my form to edit his xml file I don't think that they make any sense(ok, maybe the items but... :) and I don't include the new tags that were added later on like AUDITS...

In conclusion, I under-estimated the difficulty that was ahead (eventhough Daniel warned about :) Without the coaching of Daniel and my husband I would have never have finished it. I worked from morning till night for almost a month, the most time spending to understand how everything works and how I should organize my work... The result is 4000 !!! lines of code (the biggest I ever wrote, and I am very proud about it :) But during this project I lived moments of enormous stress :( that made me realize that I should be more reasonable next time...

4. Les commentaires de l'enseignant sur l'ensemble


Enseignant:
/ 07/ 1999

Ambitieux

Comme tu le dis toi-même, ton projet était très ambibiteux et t'as découvert quelques limites des formes HTML :). Le code marche bien effectivement (je n'ai pas trouvé d'erreurs). Une stratégie alternative (si t'as quelques semaines) serait d'écrire un parseur DTD (ou XSchéma) qui permettrait d'écrire un outil plus flexible :)
Evaluation:

Good work

Your program works according to the specifications. Editing a structure like a typical project XML-file is indeed difficult....

Note =


Enseignant:
12/ 07/ 1999

Les remarques de Sylvère - Projet 5b - Programmation: Outil de type "Tecfa campus"

L'analyse de faisabilité, les spécifications, le projet et le rapport sont présents.

Le travail effectué correspond aux spécifications préalables.

Le projet est assez proche du travail que l'on pensait faire avec une Java Applet. L'utilisation de PHP est toutefois plus efficace s'il s'agit de traiter un DTD spécifique. J'ai un doute quant à la manière dont tu as approché la programmation du code. Un DTD peut être récursif et un projet pourrait par exemple contenir des projets. Placer un menu (frame du haut) pour éditer les différents éléments du projet ne permet pas facilement d'insérer un sous projet dans un projet. Il aurait mieux valu une seule fenêtre avec des boutons pour pouvoir ajouter ou supprimer un élémentÂ… un peu à la manière des formulaires Javascript vus dans les cours précédents. Quoi qu'il en soit c'était un travail courageux pour un projet difficile.