Sunday, June 28, 2009

small xpath problem

I was met with a small problem with xpath. While learning it seemed simple. Using it in xslt, and especially with namespace makes it very complicated. I still have problem with xpath axes. I need to access the attribute value of the parent node, which is also the root node. I wrote the xpath as:
xsl:value-of select="/x:index/@userid"
However, the root node is not always same, so the absolute path doesn't work. I tried the xpath axes; however, I'm always getting syntax error, for example:
xsl:value-of select="parent::attribute::@userid"
It seems the xslt doesn't like it with I use axis more than once. I suppose perhaps I should use a node right after parent:: ? But I need to access the parent's attribute, there's no node below for me to use. What to do? I still don't know how to use the xpath axes. I'm using a lazy method for now, but it might become problematic:
xsl:value-of select="/x:*/@userid"


Update:
Oh! It's stupid!! After all the bloody searches and trials i gone through, the solution is stupidly simple. -_-# The xPath also works, in case, like dos, like normal directory - all I needed was two dots and a slash to tell it to search one level up, so:
xsl:value-of select="../@userid"
... ... ...

Project re-planning

As I am stuck on the problem with metadata adding entry. I went onto re-styling metadata.xsl & review.xsl. Then I thought it's not, very not, user-friendly and logic to have these pages. Well, from programming side of view, it's more convenient; and the functions can be grouped together. However, I cannot convince myself how any user would understand what metadata means, and why on earth would they want to read review of some random a game. I think, then, before I go into the mambo-jumbo of coding and programming. I should do a project planning - I should know what all 4 phases require, and and adjust the layout in accordance:
  1. Review page will do better embedded with the specific game it belongs to; same for add review.
  2. Metadata page needs to be taken apart, and renamed accordingly:
  3. (a) Search box should be embeded in the header of every page;
  4. (b) a Browse page(in menu bar) for user to view all games, preferably by catagory;
  5. (c) a Submit page(in menu bar) for user to add new games
  6. (d) a Game Info page for each game that will display all relevant elements; eg. review.
  7. (e) a Edit page(linked from Game Info) to edit each game
  8. A series of user interfaces: Sign-up, profile, edit profile pages; as well as a user login/logout status indicator in the header
  9. Lastly, I need a place for friends indicator, which will show name of user that's logged and have similar favorites. Will footer be a good place? um....

Sunday, June 21, 2009

IAT352 Phase I doc: change XSLT

The main objective of this phase is to change the layout/ outlook of the website. I tried to start by playing with the xslt files, eg. index.xsl; however, I was not very successful to come up with a satisfactory layout. It was a mistake to start here, to mix design with implementation. So I a went back to the scratch book, think about what content I want in the website, and what functions I need in the layout to service the content. Then, based on that, I created a layout mock with HTM, and finally went back to xslt files to convert the layout mock into xslt.

In this process of transforming the layout mock into xslt I need, I have met several problems:
  1. The formatting of the the file was very messy, even with help of CSS. There are too many classes and ids in the stylesheet. So I searched and read a few very helpful tutorial on organizing and simplify CSS style.
  2. I find the section of code describing logo and menu are reused again and again, so I tried to turn these two section of coding into a xslt tempalte, and put into header_footer.xslt. However, this was met with error. The problem came from the xml schema - xsl template, logo & menu was not defined in the schema document. Which file generates the xml schema? Failing many times after I tried to change the index.xsd file itself, I realized that the file must be generated by any file.
  3. To find the file that generates the schema file, I traced the code from indexSeverlet.java to JSPUtil.java, and find that XmlApi.createNewElement(paramater); defineds the root element; and XmlApi.createChildElement(paramater); defineds the subquent elements.
So far, I have almost completed design and transforming index.xsl page, except:
  1. I need to find the correct expression (url) for Browse menu button, which is meant to show all games in the website. href="metadata.jsp?action=search&mid={_____}" What should be in the {___} to express all mids?
  2. Metada page is not working - I can not add any entry, and always gets a Exception: null error. I am currently quiet clueless which file (metadata.xsl? MetadataServelet.java? or other?) that is causing the problem. Perhaps I can try to change the error messages to something other than null so I will know, at least what to fix. This must be fixed before I can do anything else, especially for many things in phase II.
  3. I'm keeping Forum in the menu, but I'm a little puzzled whether we need it or not. Beside, it's a broken link.
  4. I also need to design, specific layout for Metadata & Review pages (search, add, edit, browse & view).
[Archive: Project Package jun22 v1.zip]
Powered By Blogger