Thursday, January 27, 2005

Never miss a space.

I was till now, trying XSLT on Firefox.

I used to have a XML generated by a application that had to print the
<?xml-stylesheet type="text/xsl" href="somefile.xsl"?>
that would instruct the application of XSL Transformation on this XML.

I had a tough time to figure a small mistake of not having the space between the type value and href tag. My application would produce
<?xml-stylesheet type="text/xsl"href="somefile.xsl"?>

Firefox would still apply the XSL transformation to this XML. But I found that IE showed the whole document as XML. It was a really hard to figure what went wrong in IE that was perfectly fine in Firefox as it was really too late of the day and I was also looking at some other issue.

Yes, finally I had a zoom in look at the XML rendered in IE and surprisingly found a missing space in between the type tag value and href tag.

Yes, now I fixed the problem by adding a space and IE applied the XSL Transformation perfectly.

Beware, IE looks even for a space to validate :)

ContentType problem!

I was working with java servlet that would produce XML document for which I would later apply XSLT
to display the HTML on the client side.

I made a small mistake that was really hard to find out when I was trying on IE.

The IE (I was using) would display XML document by applying XSLT correctly when I requested my server to send the document first two times but when I requested for the third time then the server would send the XML document but now IE would not display it by applying XSLT. :(

Now, I went and checked whether the XML missed out the stylesheet instruction, NO I HAD.

Now, I checked whether the stylesheet is correct and it is pointing to the correct location on server, YES IT IS.

Now, I checked the same application with same actions on Firefox.

Surprised, to see that same action in Firefox would display XML document applying XSLT any number of times I send the request.
Oh, finally I fixed the problem, the server application, that is my java servlet, missed to set the content type of the response, (HttpServletResponse)response.setContentType("text/xml"); and this was the whole cause of the rendering problem.

Now, I was really surprised to see how the first two request was being shown correctly using XSLT and not the third one. :)

GreaseMonkey Plugin.

Hey, GreaseMonkey (http://greasemonkey.mozdev.org/) is really a cool extension to firefox. Using this you can customize the website you want, with your javascript.

For example:
On loading/reloading of the page (http://mail.yahoo.com) you can write a simple javascript to set the desired user name in the login box and install the script using greace monkey. And when you load the http://mail.yahoo.com you can see your java script in action.

It is quite simple to install the user java script.
(First get the grease monkey plugin installed).
1. Write a java script file having extension "user.js"
For example:
(function myOnLoad() {document.login_form.login.value="yahooId";})();
2. Open the file in the firefox.
3. Click Tools -> Install User Script
4. In the Dialog box, Edit the entry with "*" and type http://mail.yahoo.com specifying that you are installing the javascript for http://mail.yahoo.com page and press OK.
5. Open the page http://mail.yahoo.com

You can see that 'YahooId' is displayed in Login

Thats so simple. Enjoying exploring other things. :)

Thursday, January 20, 2005

Get started with XML

I wanted to get hold of some good reference to understand XML and know more about how is it being parsed how do we get the data into an application. I found few links that is really cool, that has some stuff that helps to get started with XML.

Understand XML:
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/overview/index.html

Using SAX API:
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/sax/index.html

Using DOM API:
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/dom/index.html

Using XSLT:
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/xslt/index.html

Wednesday, January 12, 2005

Decide on JSP or XSL

Its hard to decide between JSP and XSL once getting used to XSL
I found the link http://www.developer.com/xml/article.php/1380771
to be useful to know more about the usage of JSP and XSL.

This page is powered by Blogger. Isn't yours?