wood burning stoves 2.0*
The moose likes Cattle Drive and the fly likes XML for Assignment Log Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "XML for Assignment Log" Watch "XML for Assignment Log" New topic
Author

XML for Assignment Log

bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Alright, I haven't put a ton of thought into this yet, but here is my thinking for the tags we could use:

Basically, the root is the log tag with a student tag defining the student and all of thier assignments under that in assignments and assignments tags. The only difference is that the old assignemnts have an attribute completed="true" so we know not to show that one on the assignment log but we still have the history if needed.
I didn't include an active="true" type of thing yet, but we may want something like that as I said earlier.
Alright, let's all pick this apart and see what we need to add, take away or change.
Bill
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Here is the DTD that we would use for the above tagset. I figured I would just edit this as we go.

First one of those I did. Does that seem right? I does validate, but that doesn't mean I did it right, I just did it well-formed.
Bill
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
By they way, I know there are typos above, but I am not editing them because any time I edit the message, I will have to go in and replace all of the brackets with < and > again.
What a pain.
Bill
[This message has been edited by bill bozeman (edited March 27, 2001).]
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Bill,
Just a thought, not exactly sure how you are going to use the data however wouldn't it be simpler to organize the data by Assignment eg
<pre>
log
java-1
student
submitted
... other elements
end-student
.. more students
end-java-1
java-2
student
.. other elments
end-student
... more students
end-java-2
end-log
</pre>
From what I've read about XML, it's much easier to work with tags than attributes when retreiving data.
Just a thought

------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
[This message has been edited by Jane Griscti (edited March 27, 2001).]


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
You know Jane, I did think about that. I really hadn't decided which way was best, have the student be the outside tag with assignment as the child or have assignment be the outside tag with student as the child.
I think the reason I went with student as the parent was because it seemed a little more intuitive to me. Well, I don't know if that is true, because a good argument could be made for the other way around. To me it just seemed that students with all the assignments would be the easiest when making edits and doing a lookup on where the students were because all of their stuff would be grouped together. So it just seemed a little more natural.
What do others think? This one could go either way, so how about we take a quick vote and make our arguments.
Doing it by student as the parent would seem to imply that the student is the more important item, and what assignments they have done and are currently working on directly relates to that student. This would make updating or looking up student records more logical I would think.
Doing it by assignment as the parent would imply that the assignment is what runs this and the assignment would be of more importance with the student being secondary. This would make gathering data about an assignment and making the college easier and more logical to update.
So which way does everyone feel more comfortable with? To me they both are valid, but I think I will vote for student as the parent.
Bill
Daniel Olson
Ranch Hand

Joined: Jan 05, 2001
Posts: 81
With the little bit of work I have done with XML and Java, I haven't found attributes more difficult to work with than tags. The way that best represents the data should determine which we use. I haven't done anything complicated yet and may eat my words when I do.
As far as whether to have the student or the assignment as the parent, we might want to do it both ways. The assignment as parent for the table that shows where students are currently at--like Johannes' table. The student as the parent for history and statistics.
To start with for phase 1, I suggest very a simple organization with the student as the parent where we are only representing where students are currently.
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
This might sound silly, and I don't know XML, but can't you have it both ways? A simple cross-reference would allow the student and the classes to be independent of each other. Then, you could simply have stylized output for the sort of report you want without being tied to a single heirarchy.
Imagine standard college courses:
- Students want to review only the classes specific to them...what have I done, how did I do, what do I need to graduate, etc.
- Professors want to review only the classes they are teaching... who are the students, how many students, what is the average grade in the past, etc.
- Administrators want to review everything, but from different views for different tasks.
I guess what I'm saying is that it doesn't necessarily make sense to have either be the 'parent' when it is perfectly justifiable to want either at any particular time. It's basic DB design...
Just thinkin' out loud!

------------------

Joel Cochran


Wait a minute, I'm trying to think of something clever to say...<p>Joel
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Joel, when I think of it in terms of database design, that is how I would think of it. Make it fully relational, so anyone can easily look at in anyway they want.
But we are working with XML and not a database, so there should be a hierarchy of tags that we use. We could use IDREF and stuff like that so that the assignments could be in a different tag set that we lookup, but I just felt that would be overly complicated.
And Daniel, we could do it both ways, but that isn't really the point of XML, I think. We want to have all the data in one file that we can parse through and show in multiple formats. If we have the data twice in two files, that gives us two places to make updates and two places where things could go wrong or get out of sync.
Really, I don't think this matters much. We can parse through it either way and get the data we want. My thinking goes with if you were to just look at the XML and not any kind of style sheet or display, would you be more likely to look at a student and thier related assignments, or look at an assignment with all the students who are or have done it?
Bill
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hmmm ... maybe we should get the Great and Powerful Map and Ajith to take a look; they're the resident XML experts ...
Your right Bill .. the way we're going to use the data should be the key in choosing the initial design.
Jane
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
My thoughts exactly. I already posted a topic in the XML forum trying to get Ajith and others to take a look.
Bill
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
I dind't have time to go through all the old discussions related to this topic. I only browsed through them and so I'm making the following assumptions -

  • The problem at hand is keeping track of students and assignment submissions.
  • XML will be used as the primary medium of storage.
  • We are not even considering relational tables and using XML as adhoc storage format.
  • Being able to search the XML tree is as important as rendering the XML data.
  • We are talking about significant amount of data - few dozen assignments and a few hundred students.


  • I think there are two issues involved here -
    What should be contained in what? ( Should student contain assignments or assignments contains students.
    This really depends on whether you want the data to be student-centric or assignment centric.
    Approach 1 :
    The student-centric approach( proposed by Bill ) tends to create a broader XML tree with fewer level of nodes. ie., all the first-level nodes are students which means the more students you have, the "wider" will be the tree. But each student can have subnodes which are atmost equal to number of assignments. So the tree is not just broader, but also shallow.
    Approach 2 :
    The assignment-centric approach ( proposed by Jane ) creates a deeper XML tree. Since the number of assignments is significantly smaller than the number of students, the first level of nodes( assignments ) aren't that many. However under each assignment node, there can be a huge number of students which makes the tree deep rather than wide.
    Having that said, I simply cannot advocate the use of any one of them without being clear about the requirements. Neither of these designs is a cure-all. If the typical use of data is querying by student, you are better off with the student-centric approach since the parser will do a breadth-first search returning fewer nodes. On the other hand if you plan to do quite a lot of assignment-based search go for Jane's design.

    We all know breadth-first searches are usually more efficient than the depth-first. Consider the usage pattern - I want to see all the assignments submitted by a student. In a student centric approach, the XPath can quickly get the student element and return it since all assignments are found contained in the student nodeset. However, if you were to adopt the assignment-centric approach you will be left with no option, but to visit every assignment node to inspect whether a student is present in its subnodes. As the number of students increase, the 'depth' of the tree-traversal for each assignment node also increases. XSL transformation engines use DOM parsing for creating result trees. Eventhough the two approaches has no specific benefit in terms of resource consumption with respect to each other, the speed of parsing can be greatly improved by making use of optimal hierarchical structure. Remember, both the approaches eventually result in same number of nodes = number of students * number of assignments. So designing for better memory utilisation isn't an issue here, designing for speed is.

    Now for the next issue - Should we use attributes or elements.
    The rule of thumb is, attriutes should be used for "internal" data. Elements should be used for the real data that is displayed to the user. To give you an example, if you were to use an internal id for each student, that would be an ideal candidate for being an attribute. It is a part of the data, but isn't really the 'real' data. Examples for real data are the name of the student, or the date on which the assignment was sumbitted etc. These should certainly be modelled as elements.

    Again, think about how you plan to use the attribute. Querying on attribute values isn't really recommended but people do it all the time. The advantage of doing it is that, if you modelled it right, you only will inspect the attribute value of the parent node and infer something about the child nodes. Since childnodes dont' get involved in this querying process, you are traversing the XML tree breadth first..... and I have said enough about how it is better
    Use attributes to describe to the processing software( not to the user ) some useful information about the current node and/or its children. For example if you map an XML document to a relational table, attribute for each record( corresponding to each composite XML element ) should probably store the primary key of the record. When it comes to updating/deleting/inserting it is easier to retrieve and use the key instead of building the key from one of the subelements.
    Hope this gives you all something to think about.
    Cheers!
    ------------------
    Ajith Kallambella M.
    Sun Certified Programmer for the Java�2 Platform.
    IBM Certified Developer - XML and Related Technologies, V1.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I've got a few comments if you are interested...
First, a trick you can use to fool the Ranch into displaying your tags properly is to put a space after each < and before each >. This is not treally valid XML, but it's easy to fix with a text editor if you need to, and is pretty much as readable to a human.
Second. I am always extremely wary of storing dates in any sort of text form without an indication of how to parse the date. You must remember that European dates go dd/MM/yyyy or sometimes yyyy/MM/dd, and US dates typically go M/d/yy or M/d/yyyy. I hope you notice that I am using a standard form for describing these dates. It is in fact the same format as used by java.text.SimpleDateFormat, so making dates elements and marking them up with such an attribute would make them easily and robustly parseable by Java.
Third, I am also wary of duplicating data. In your example you have both the id and the name of each assignment for each student. This would mean that the name of each assignment could appear hundreds of times in the data, with a corresponding chance of getting it wrong. I suggest a separate subsection of assignment data, which is used (if required) during presentation. Arbitrary other data about assigments (some sort of "points" value, a "toughness" rating, the area of interest, keywords, etc.) can then be added to the assignment data without disturbing anything else.
Fourth, I don't feel that < student > should be right at the top. It is much more robust for parsing and stylesheets if all < student > elements are grouped together under a < students > element. This has the useful side-effect of allowing other groups of data to be placed in the log element without requiring any changes to the parsing or stylesheet processing of student-assignment data.
Fifth, The rule I apply when deciding if something should be an attribute or an element, is that attributes should only be used where the content of the value is either constrained to a known set of values or to a known pattern. This is important, because the rules about what characters are valid in an attribute are stricter than for an element. With that in mind, I suggest that a free-format value like the name of an assignment should really be an element rather than an attribute.
Sixth, I'm not entirely sure what is meant by some of the tags in the example at the start of the thread, in particular I'm gessing about the meaning of the "date" attribute of a student = I doubt that it is his/her birthday!. I suggest some slighly more detailed names to help make it clear what the data means.
Seventh, I don't think "completed" should really be a boolean attribute of a student's assignment. Wouldn't a date-completed element be just as useful, and contain more information? If there is no date-completed, it hasn't been completed!
Finally, here is an attempt at rewriting Bill's original example as per the above suggestions. All criticism welcomed.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Hey, thanks a lot Frank and Ajith. Your comments make a lot of sense and are things I didn't know or think about.
Frank, I like the example you provide. One question though. You make name an element of assignment (which I agree with) but you make name an attribute of student. I would think we could use the same tag definition for both assignment and student and make them both child elements, kind of like you have for date-started being both for a particular assignment and for a student. By the way, for an explanation, date-started for a student is the date they first registered, and date-started for an assignment is the date they started a particular assignment.
The only other thing I think we may want to add is something that tells us whether this is an active record or not. I don't really want to delete the record because maybe someone leaves for 6 months, but then comes back. Going along with Franks and Ajiths suggestions, this is really not for display but more of internal data, so I would think it would be more of an attribute rather than an element. Maybe name it active and default it to true.
Thanks again for your comments. This is my first XML thing and I knew I was getting in a little over my head, which is probably why I was suggesting database design to begin with
Bill

[This message has been edited by bill bozeman (edited March 28, 2001).]
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
I really liked Frank's proposal for adding another hierarchy of assignments within the same documents...cleaner design, easy to maintain and very
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
By all means make student name an element rather than an attribute. I guess I was implicitly treating it as a unique id, but that's not a very robust assumption. If you want to be extra cunning, you can allocate each student a simple, unique id (like a student-id number) and have that as an attribute. That way, you can handle it if two students with the same name try to use the system, it makes setting up an inverted structure with references a lot easier, and makes it simpler to build a web UI for maintenance (less gratuitous URL-escaping and no real chance of mis-spelling or typos).
What worries me about a separate "active" attribute is similar to what worried me about the "completed" flag. It's not in the file but in the process for using it. How do you imagine this "active" flag will be set or unset? I'm guessing it would have to be a manual operation, and that seems to imply a lot of pointless extra work.
How about some sort of "most recent activity date" (one of the dates there may be doing this job already, the example is a little small for me to tell how this is proposed to work). Then the decision of whether someone is "active" or "inactive" can be coded as software or a stylesheet, and any new activity will automatically "reactivate" the student without any manual intervention.
The timeout interval is then a property of the particular report being produced, rather than being implied by the data. I might want to see the latest assignment completed by all students who have been active in the last month; you might want to see a table of assignment progress for all students who have been active in the last six months.
The basic principle here is that the XML should only contain fundamental, orthogonal data. Anything which can be derived from data which is already there should be left to external processing. This should be familiar from notions of database normalization.
Daniel Olson
Ranch Hand

Joined: Jan 05, 2001
Posts: 81
Originally posted by bill bozeman:
And Daniel, we could do it both ways, but that isn't really the point of XML, I think. We want to have all the data in one file that we can parse through and show in multiple formats. If we have the data twice in two files, that gives us two places to make updates and two places where things could go wrong or get out of sync.

The reason I suggested doing it both ways was because the goal of phase 1 was to reproduce Johannes' table. That means all we need is a very small XML file. It needs only enough information to know where students currently are. Keeping the file small will make parsing through it faster.
The design everyone is discussing will have a history of every assignment every student has done. I think that would be good to have, but it will of course be significantly larger and slower.
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
I agree with Daniel. Phase 1 should be to replace my manual data entry. For this I think a simple XML solution with my current fields should suffice. With maybe one or two for flow control, ie. can he update or not, and maybe a password to control that its the right person updating.
[This message has been edited by Johannes de Jong (edited March 28, 2001).]
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Frank you are right about the active thing. I was thinking of it in terms of what if we need to take someone down because they no longer want to be on the list or they were mistakenly put into the list twice. But in all those circumstances, it would make more sense to delete the person from the list rather than make them inactive, because they don't really need to be there in the first place.
Daniel, I see what you are saying, but I think if we design it like Frank and Ajith mentioned above, it wouldn't really be that much extra work, and it allows us to start collecting data now. My fear of waiting would be that we now have this simple thing up that took us 2 weeks to build and then we start populating it with data. We overwrite data as people move through the classes. But then we start saying we want to keep history on everyone and we implent that a month later, well then we lose a months worth of data. While if we took the extra steps from the beginning, to really figure out what we wanted, then it may take 3 weeks, but we don't lose data.
However, I am assuming that we want to keep the history of students. Personally I like having that because it helps us analyze the CattleDrive. What is the average number of attempts for Say? How far to students get before they usually drop out? How long (in terms of days or months) does it take to complete a particular assignment? However, maybe we don't need to know that stuff. I just love stats, so I always think in those terms. But maybe we don't need them.
Marilyn, I think the above question is more for you. What do you think? Do we go with a more robust, but more complicated and more time to build solution like Frank has shown? Or do we scale it back and just get the basic stuff up?
Bill
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Jo, one more thing. If this starts to become a lot of extra work for you, how about I help out. I can't edit your post because I am not a sheriff or moderator of this forum, but I can start a new thread for the log and copy what you did. That way, I'll take control of it for a couple of weeks. Then maybe Daniel can do the same, that way we can share the load.
Also, do eiter of you want to start on the HTML for both the data entry and the class list? No matter how we do this, we are going to need to have those HTML files. I would just stick with the colors we use on this site, and give room at the top of the page for the JavaRanch navigation that we have on the top.
For the data entry pages, we need one page for users to register, and I think we said that is just going to be name and a password so other users can't edit thier stuff (does this mean we need to add a password to the XML pages? I am so lost outside my world of DB ). And then we need a page where someone can enter thier username and password and select from a drop-down list which assignment they are on. All the date stuff will be server side and attempts will be server side also. Does that sound right? It seems that I am missing something.
I'll start a new thread so we can discuss and view the HTML files.
Bill
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Dont worry Bill I'll cope thanks for the offer. You think you are lost, man if this was the mainframe world I would have been finished already.
By the way what should I download/have for this project, ie to test servlets, xml etc.?
I agree with you that the "look-and-feel" should be the same as used in the whole of the Java Ranch. (actually cant see Paul allowing us anything else )
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Originally posted by bill bozeman:
Daniel, I see what you are saying, but I think if we design it like Frank and Ajith mentioned above, it wouldn't really be that much extra work, and it allows us to start collecting data now.

However, I am assuming that we want to keep the history of students. Personally I like having that because it helps us analyze the CattleDrive. What is the average number of attempts for Say? How far do students get before they usually drop out? How long (in terms of days or months) does it take to complete a particular assignment?

Marilyn, I think the above question is more for you. What do you think? Do we go with a more robust, but more complicated and more time to build solution like Frank has shown? Or do we scale it back and just get the basic stuff up?

I like stats too. It wasn't so bad when there were only 3 students at a time to manually collect stats, but at the rate students are joining the cattle drive, it is rapidly becoming to complex and time-consuming to keep track of.

Of course, we'll probably have to decide exactly what stats we want and will be able to get from the design we plan to implement.

How many new students/day
How many students on a particular assignment at a particular point in time (workload stats on nitpickers)
Total number of active students


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Han,
For servlet info go to http://www.javaranch.com/drive/servlet/index.jsp
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Does that mean I'm promoted to High Schools , thanks.
Daniel Olson
Ranch Hand

Joined: Jan 05, 2001
Posts: 81
Have any of you had the chance to look at the files I emailed yet? It has a working example of Servlets using XML to modify the equivalent of Johannes' table. I wish we had a public server where we could see a demo of it. I checked mycgiserver and webappcabaret, but they don't have JDOM. There are four files for the working example:
ClassLog.java - displays the table
ClassLogEdit.java - For editing one record of the table
SiteUtils.java - has utility methods for handling XML
ClassLog.xml - the XML file for storing ClassLog data
The servlets have all the html needed for display purposes. It does not have the JavaRanch look and feel, but that would be easy to add. Also, eventhough it is a working example, it needs several enhancements--such as the authentication for edit page. The authentication part shouldn't be too difficult. Can't we plug into the Authentication JavaRanch already uses and store the username in a session variable?
Last night I added sorting functionality to the example. By default it sorts by Assignment, but a user can click on any heading to have it sort by that column. The sort names assignment came in handy for that
Daniel Olson
Ranch Hand

Joined: Jan 05, 2001
Posts: 81
I like stats too. More than the extra work, I was thinking about the XML file size and performance. Right now there are about 50 students. For just keeping stats on the current assignment that would be a fairly small file. However, there are more than 20 assignments so far if count a and b versions and the JDBC. That would be quite a bit more to parse through for the table display. That's why I thought we could have a small file with better performance for the table display since that would be the one accessed most often. We could also write historical information to the bigger file, which would be access less often by fewer people. I don't know whether the file size is that important or not. I was just thinking that parsing through 50 lines would be faster than parsing through 5000 lines (50 students * 20 assignments * 5 lines of tags). Of course many students don't get past the first few assignments, so that is just a guess about the size. Frank Carver said in a post, "As with any peformance issue, it is vital that you actually test things rather than making assumptions." I haven't tested this and if there is not a performance issue, I am all for having the larger more complete file as the input file for displaying the table.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Daniel, yes I did look at your stuff. Thanks for sending it over. I am going to talk with our resident XML gurus here (Ajith, Map, Frank...) and see if we are using Java to parse through the XML to show the data or are we using XSL and cocoon to parse through it.
We will need Java to add and change records, but I am not sure about the display part of it. Also, I don't know what performance would be like. We may be able to have it when someone completes an assignment the old record moves out of that tag set into a history tag set and then you add the new assignment. I say we just try it this way first and then test the performance because I just am not sure what it would be like. Someone could tell us, but it would probably hit home more if we just test it ourselves, at least that is one of the best ways for me to learn.
I'll let you know if we use JDOM here or cocoon or what.
Bill
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

Howdy fellas,
I just saw about this website yesterday, I think it's perfect
for prototyping/develop this project.
This is Java website that gives out 10MB of space to
develop Java apps, and they support pretty much most of
the Java Web related technology - JSP/Servlet, JDBC, XML, etc.
The URL is:
http://java.isavvix.com/show.jsp?p=devspace.jsp
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Daniel,
Just compiled and ran your example .. it's a great start!
Thanks for sharing.
Jane
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Where do you get the time Jane?, if I touched my computer last night she would have murdered me. I'll test, run & play with it this weekend I promise Daniel
Thanks Ryo. Will create a user id for myself this weekend.
[This message has been edited by Johannes de Jong (edited March 29, 2001).]
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Hey Jane, I was trying to look at some of the older posts on the project that you, Map, Ajith, and Carl were working on. Did you use XSL and Cocoon to display the FAQ pages? Also, what are you using to update the pages (servlet, JDOM, etc..)?
I have been trying to set something up at my work so I can play with cocoon locally before putting up on my test spot on Javaranch.
Bill
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Bill,
No ... Map and I cheated We wrote the XML then converted it from the command line and uploaded the result. We've been trying, desperately, to figure out how to set up add/edit functions on-line. Daniels code is a real breakthrough for us Although I can't get it to run on the Ranch; think the classes have to be in a servlet directory; they won't work from test/vroot.
I've been playing with JSP's and taglibs, which what Carl used for the Bunkhouse review page but think he's got a class somewhere behind the scenes to do the addition/update.
Jane
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Johannes,
I only work part-time and refuse to do housework during the week ... plus, my husbands a work-aholic ... so he can't yell if I'm on the computer alot ... 'cause he's on his ... now if only I can get my kids to stop complaining because I won't let them surf! You'd think I upgraded to broadband just so they can listen to mp3's
Jane
[This message has been edited by Jane Griscti (edited March 30, 2001).]
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Hi Bill!
Regarding your questions:
We use XSL file to display XML file. Cocoon is not installed and probably will not be installed in near future. Cocoon has tag library which along with other stuff allows to edit XML documents. but, as Carl said, this tag library conflicts with JSP, so even of Cocoon will be installed we seems will not be able yo use �XML editing� feature.
I was trying to find some �cheap� solution to update the pages, without going into hard programming. It is such a typical problem: to have html interface to allow users to edit XML, I was sure there are some service programs somewhere on the Internet. Ha-ha, no such luck. Besides, we have a peculiar requirement: in content of some tags, such as �answer�, we intensively use HTML tags for markup: < p>, < ul>... When tags content goes for editing, we want it to be displayed �as is�, so people can cut&paste html chunks. I used XSL document to convert a part of XML to HTML form for editing purpose. Everything worked just perfect, but all markup from < answer> tag was gone and only text was shown. I tried to make XSL to show content �as is�, but was not lucky. Then I waited a little hoping that Ajith or Carl will solve all our problems, but for some reason they did not Finally I decided to bury myself with DOM/SAX. Two days ago I started to use JDOM and it is very good! Everything was easy. I have a version of XML editing program which works locally, now I am struggling with combining it with XSL and JSP.
If you want more details: I did not want to write a program to edit �JavaRanch FAQ xml file�, I wanted a bit more generic approach, to use the same program for contact page or moderators file, for example. I assumed that XML files have kind of �table� structure:
< root element>
< element id=�a1�>... some data here< /element>
< element id=�a2�>... some data here< /element>
< element id=�a3�>... some data here< /element>
...
< /root element>
where elements are �rows� and inner tags are �columns� (not only you have relational database background and not only you see everything in the world as tables )
Then I wanted to have XSL styleshet which is run against this xml document.
Xalan XSL processor allows to pass a parameter into XSL document, which in our case will be id value of an element we want to edit. Then in XSL stylesheet we code:
< xsl:template match = "id($specifiedId)">
...
and this XSL stylesheet will work on one element with specified id.
In XSL we can use whatever HTML we want. I put there HTML tags to create HTML form for editing. We can intermix HTML tags and XSLT elements to make form show XML data:
< textarea name="Answer" rows="7" cols="80">
< xsl:value-of select="./answer"/>
< /textarea>
to tune �look and feel�, we can call CSS stylesheet and put all font and color information there. This way logic will be neatly separated from presentation.

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
To Daniel:
I was sent your program (see - you become famous and your program is this week JavaRanch�s hit ). Unfortunately I couldn�t make it work on my machine since I am not good with servlets so I just looked at your code. I asked in MO forum if we can have JDOM somewhere on this site for testing, if yes, we can put your package on testing part of JavaRanch site so everybody can test it
I have only one remark. You hardcode everything inside your program: file with XML document, HTML for presentation, field names for editing... It would be better if logic was separated from presentation. For example, you could have XSL stylesheet to run against XML document and generate HTML form for editing, and then your program would be called from HTML form, with parameters:
?fileName=/ClassLog.xml&nodeName=StudentName&nodeValue=Johannes de Jong...
This way your program could serve several HTML forms, one for students and one for assignments, for example. It would be also possible to change �look and feel� of these forms without changing your program.
I am trying to put my FAQ files on the Ranch site for illustration, so you can see how it may look like...
Daniel Olson
Ranch Hand

Joined: Jan 05, 2001
Posts: 81
Mapraputa:
Thanks for you comments on the servlets I wrote. I agree that it would be better to not hardcode everything. I wrote the servlets as a demo of how to read from and write to an XML file as a first step in trying to automate Johannes' assignment log table.
I would love to see your code when you finish the FAQ program.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Map,
Thanks a bunch!!! I had been trying to figure it out all weekend, do we use cocoon, do we use JSP and servlets, do we just use I/O classes, do we use JDOM, or is JDOM even in our classpath here.
Your comments really cleared somethings up for me. One thing for us is fortunate, we don't have HTML tags intermixed with our XML.
One more question, what is doing the translation from XSL and XML into HTML since we don't have cocoon?
Also, so you come from the database side of things also. Which one do you like better? Or do you just see needs for both and it just depends on the situation, which is what I am beginning to think is true.
Thanks again,
Bill
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
To Bill:
I had been trying to figure it out all weekend, do we use cocoon, do we use JSP and servlets, do we just use I/O classes, do we use JDOM, or is JDOM even in our classpath here.
He-he... To confuse you even more: to transform XML into HTML we use... ah, actually we do not use... Ok, we can use XSL taglib which is part of Jakarata taglib . This is from Carl�s JSP:

Not sure I used �relative path� term in right sense,though. To make it clear:
if your XML document is on [www.javaRanch.com/moderators/Bill/classLog.xml]
ans XSL document is on
[www.javaRanch.com/moderators/Bill/classLog.xsl]
then < xsl:apply tag will look like:

We decided not to call transformation dynamically because our FAQ pages are not being updated few times a day so it doesn't make a lot of sense to transform XML to HTML every time somebody wants to look at FAQ. Instead, we will do transformation locally every time FAQ is updated and simply put resulting HTML on the site. But in your case dynamic transformation makes sense, since everybody can update XML source at any time.
I was trying to upload an example of XSL which is called with parameter, but it turned out that < xsl:apply tag doesn�t allow to pass a parameter into XSL We can either change XSL:apply tag behaviour or to write our own small JSP instead, something like this:

I tried this, but for the code to work we have to import a lot of other classes, and some of them, of course, were not found on JavaRanch... What a surprise! (Map is being sarcastic). I will wait until Carl figures out the situation with JDOM and then attack him with the next portion of questions... . I got Carl�s E-mail this morning; he said that we can install JDOM, but he has to check if it conflicts with something else. He will report results tomorrow.
[This message has been edited by Mapraputa Is (edited April 02, 2001).]
(Marilyn shortened the line length to avoid extra-wide thread.)
[This message has been edited by Marilyn deQueiroz (edited April 02, 2001).]
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Cool, thank Map. Let us know if we can use JDOM and then we will update the XML with JDOM and display the table with the XSL taglib example you showed.
With that said, Johannes, Daniel and Marilyn, how about I put together a sample XML page and XSL page and try to run it through the JSP example that Map provided.
I may not be able to play with this until later this week, but I'll let you know.
Bill
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Bill to tell you the truth, I'm totally out of my depth here. Heck I read trough a printout of the postings in this topic last night in bed and I could not even figure out the difference between tags and attributes. I'm a dead-weight to you guys.
So please move on dont even ask me for my permission.
If there is dumb work that needs to be done. Let me know.
Daniel Olson
Ranch Hand

Joined: Jan 05, 2001
Posts: 81
Bill, I'm with Johannes. I don't have enough experence with and knowlege of the different technologies to be much of a help to this project.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML for Assignment Log
 
Similar Threads
Current List of Pending Assignments
about instanceof .
Creation of Tree View : dealing with laternate rows
Movie Taglines
Assignment Log Project