www.rokni.com

Skip navigation
XML and XSL

XML and XSL, Why and how?

Why? well, I am not going to tell why XML is cool, instead, what I can do is linking you to this article "Why XML?" from xml.com.

But how? that's a good question. I am going to post some pages that I've created and you may find useful as an example of XML, XSL, XSLT and CSS.

Keep in mind that to learn XML and XSL, you need to know html (of course if you want to transform data to html format) and css very well and what I mean by very well is that you have to be very precise in your html coding/programming, because first of all, XML doesn't tolerate any mistake on spelling and inconsistency and as you may know XML page has to be well-formed and valid, and second, XSL combines XML elements with html elements and can use css to create a style for it (it's lot easier to maintain whole site using css).

The result would be html page which any browser can read. Needless to say that in this way you separate data from formatting, so you make it easier to transfer data in a fashionable way without any modification to the data. Wow!!! What a lecture.

Web Pages Examples

Hello World: Please visit (Again, Hello World) page to see the source code for XML and XSLT as well as XSLT in action.

My Resume is an example of XML/XSL/HTML version of my resume which is one of those pages. It uses Apache Cocoon which is an XML publishing framework that raises the usage of XML and XSLT technologies for server applications. So, as a result of transforming, you will see an HTML output.

There is another page (resume as you may expect but dated) which uses XML codes, DTD and CSS (it's a valid css) working on Opera, Mozilla -latest version- and Internet Explorer. Check it out.

Yet another example is the same version of my resume which uses Apache AxKit. It is an XML Application Server for transforming XML documents by XSLT to HTML or other forms. So, as a result of transforming, you will see an HTML output.

Web Application Example

Time Sheet: I have done a short project working on a time sheet, check the HTML output and XML/XSLT using Cocoon output to use some functions of XSLT with XML data collection capabilities. The object is to enter some data using xml, then using some xslt math functions to get total sum of those numeric data and transform to different format (minutes to hour) while it finally generates an html page to create a processed form (wow, another long boaring lecture. Wait, read the rest of it, I will post yet another interesting note about how this works or suppose to work).

To do the job locally I have used Saxon and used Cocoon online, therfore I have changed some codes. For example, In Saxon I used "xsl:text" with disable-output-escaping equals to "yes" CDATA as non brake space. In Cocoon the same "xsl:text" didn't work, so I have changed it to shim gif to show proper spacing.

I will do more stuff (add some other cool functions to see how they work) later as I am digging more deeply, also, I want to create a valid xhtml page using xslt and css to use more of margin and padding instead of shim gif, so it would be more accessible. Also, the source code is available at this place to look.

There are very good sources for getting more information about these topics, you can check W3C's Extensible Markup Language (XML) , W3C's Extensible Stylesheet Language (XSL) , W3C's Cascading Style Sheets.

I have installed AxKit on my Apache server to transform my XML data by XSL to HTML or other formats. As a result of transforming, you will see (when ever the server is running -not much recently-) my resume as an HTML output. Although, it should transform those files in the run time but seems it needs more time to do this job, as a result some times you see "500 Internal Server Error"(Note).

Finally, I am getting ready to install (on my server) Xalan-Java which is an XSLT processor for transforming XML documents into HTML, text, or other XML document types. It implements the W3C Recommendations for XSL Transformations (XSLT) and the XML Path Language (XPath). It can be used from the command line, in an applet or a servlet, or as a module in other program.

Note: If you encounter a "500 Internal Server Error", when you are visiting the XML/XSL running on my server reload (hit the browser's refresh button) the page and of course be patient.

By the way, recently most of the time my server is off the net.

1999-2005 © rokni.com