Using XSL Stylesheets to Translate XML into HTML, Part 2By Arno Jansen
In Part 1 we looked at the various components of the XSL stylesheet for each part of the memo-style information: the TO, FROM, SUBJECT, etc. At this part we'll look at putting all of this information together!
Now we know how to display the from tag, we also know how to display the TO, the SUBJECT and the MESSAGE tags. And you can make up the HTML output as fancy as you like, as long as you keep the three basic "XML rules of engagement" in mind, which are:
- All tags that are opened, have to closed also and cannot have overlapping tags, only nested tags.
<I><U>something</U></I>is okay, but
<I><U>something</I></U>is not okay)
- All values of attributes have to be between quotes. (e.g.
<TABLE BORDER="1">instead of
- All tags are case sensitive. This means that
<I>has to be closed by a
</I>tag, and not a
One small note is needed here: all empty tags (the ones that do not have a specific closing tag, such as
<HR>) need to have a forward slash
just before there greater-than bracket. So,
Now we need enough to make the complete stylesheet for viewing a memo, which can be seen below.
In Part 3 we'll look at ways to extend the XSL stylesheet to allow for a more detailed HTML output!