; Case
Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out
Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Case

VIEWS: 5 PAGES: 4

  • pg 1
									An XJ Implementation: A simple list of marks on a University
In this implementation there is an XML scheme marks.xml containing courses on a university and
the grades students made on the representative course. The program MarkList displays reading
and writing of the XML scheme in XJ as well as a way to use the data in the XML scheme. Removal
of data is not shown directly because the simple way hasn’t been implemented yet (the remove()
methods are not yet implemented or even unsupported) and the difficult way of removing is
almost the same as adding. A walkthrough of this implementation can be found at [Appendix 1]

User Experience.
The first thing that was clear when using XJ was that the compiler is still in a beta phase. Decent
documentation about the supported methods is very hard to find, if not completely nonexistent.

First of all there were the problems with parts that officially have not been implemented by the XJ
developers yet. It is still impossible to put XPath expressions in the left-hand part of assignment
statements, which would have made some parts a lot easier. Another thing that was impossible to
use (and not mentioned in the manual) was the XMLCursor.remove() method, which has not yet
been implemented either. Strangely enough this was noted in a compilation error that showed up
when trying to use this method. Secondly there were the unsupported features that were not
shown anyware as being unsupported. For example, one of the publications[1] noted something
about Sequence.insertAfter() and Sequence.insertBefore() methods, but they were nowhere in the
official manual and the compiler was unable to resolve them as well. The strangest unsupported
feature is that the Sequence<E> type does not support a remove() method. This is not mentioned
as an upcoming feature. Finally there was the problem with the bad documentation of the
supported methods and elements. , for example, we had to find out how to add java variables to
an XPath expression by looking through the, also badly commented, example files.

All of these problems posed some major problems with our implementation. For example when
adding marks (courseMark) to a course (markList) in our program. As fas as we know, it's not
possible to just add a courseMark to a markList that is in a Sequence<markList>. Furthermore it's
impossible to remove an element from that Sequence<markList> to remove the old marks
information. When updating a course with new marks. We've eventually found a way to add marks
to a course through a needlessly complicated system using a new list of the entire
coursesMarkLists, containing all of the markLists except the markList which needs the courseMark.
The courseMarks of this markList are copied to a Sequence<courseMark>, the new courseMark is
added, a new markList is constructed and that markList is added to the new coursesMarkLists
object. This should be made more simple.

The part of XJ that has been properly implemented and is properly documented is quite easy to
use after a little bit of study on the XPath syntax and the XJ manual. In our opinion, the XJ
compiler is certainly not ready for commercial use at the moment. Some critical parts simply have
not been implemented yet, the documentation is mediocre and the compiler errors aren't really
helpful either.
APPENDIX 1:     MarkList Application Walkthrough

To show the functionality of the MarkList program, here is a walkthrough of the application.
First of all, make sure the classpath is equal to the samples directory of the XJ installation.
Otherwise it’s impossible to use the methods and types supported by XJ.
Compile the .java and .xj files (OOJ/Console.Class provided by “Programming 1” course)
Then start the gui with the xml file to be used as an option. In this case marks.xml is provided.
xj MarkListUI marks.xml

Now the main menu is shown together with its options.
CourseList Main Menu
Display all courses +stats                   (c)
Display one course +stats                    (o)
Add a course                                 (u)
Add results to a course                      (r)
Save XML                                     (s)
Exit                                         (e)
Make a choice please:

First, select the “Display all courses +stats” by entering 'c'. Now it shows the available courses and
some statistics about them.
Course List

Course: XTEQ
Student: 19577 Mark: 10
Student: 19410 Mark: 9
High:10 Low:9 Mean:9.5

Course: DEBT
Student: 19577 Mark: 8
Student: 19410 Mark: 9
High:9 Low:8 Mean:8.5


Highest of all courses: 10
Lowest of all courses: 8
Mean of all courses: 9.0

Now, select “Display one course + stats by entering 'o'. Now it asks for the course to be displayed.
First, enter a name of a nonexistent course (for example NONE, not XMLT or DEBT). The program
shows that the course is not found.
Which Course? NONE
Course Not Found

Reselect the “Display one course” again and now enter an existant course (DEBT). The program
now displays the course information for DEBT and the main menu.
Course: DEBT
Student: 19577 Mark: 8
Student: 19410 Mark: 9
High:9 Low:8 Mean:8.5

Next we add a course (select by entering 'u'). Enter PRG1 as name.
Make a choice please: u
What is the course codename? PRG1
Now check if the actual course was added, by selecting 'c'.
Course List

Course: XTEQ
Student: 19577 Mark: 10
Student: 19410 Mark: 9
High:10 Low:9 Mean:9.5

Course: DEBT
Student: 19577 Mark: 8
Student: 19410 Mark: 9
High:9 Low:8 Mean:8.5

Course: PRG1
High:0 Low:0 Mean:0.0



Highest of all courses: 10
Lowest of all courses: 8
Mean of all courses: 9.0

Note that the courses without marks are not counted with the “all courses” stats.

Now we add results to the course we just added. This is done seperately so it is possible to add
marks to a course that already has been created and to be able to show courses without marks.

Enter 'r' as a choice. Enter PRG1 as course name, 12345 as student number and 5 as the mark.
This could be any value, as long as the student is an integer and the mark an integer between 1
and 10. Now we check if the mark has been added to the course by viewing the course itself.
Enter 'o' and enter PRG1 as the course name. Now the course statistics are shown.
Course: PRG1
Student: 12345 Mark: 5
High:5 Low:5 Mean:5.0

Now we save the added course to an xml file by entering 's'. enter marks2.xml as the name.
To verify that the file has actually been saved, exit the program by entering 'e' and then restart
the program with marks2.xml as the used xml file.
xj MarkListUI marks2.xml

Now select the “Show all Courses” again by entering 'c'. The course is still there.
Course List

Course: XTEQ
Student: 19577 Mark: 10
Student: 19410 Mark: 9
High:10 Low:9 Mean:9.5

Course: DEBT
Student: 19577 Mark: 8
Student: 19410 Mark: 9
High:9 Low:8 Mean:8.5

Course: PRG1
Student: 12345 Mark: 5
High:5 Low:5 Mean:5.0


Highest of all courses: 10
Lowest of all courses: 5
Mean of all courses: 8.2

As shown, the program written in java with the use of XJ is able to query the XML schema, able to
process the information and able to add information to the XML schema.
RESOURCES

[1] M.Harren, M. Raghavachari, O. Shmueli, M. G. Burke, R. Bordawekar, I. Pechtchanski, and V.
Sarkar, XJ: Facilitating XML Processing in Java, To appear at World Wide Web (WWW), May
2005

								
To top