When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Sunday, August 13, 2000

Using XSL Stylesheets to Translate XML into HTML, Part 2

By Arno Jansen

  • Read Part 1

  • 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!

    - continued -

    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. (e.g. <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 <TABLE BORDER=1>).

    • All tags are case sensitive. This means that <I> has to be closed by a </I> tag, and not a </i> tag.

    One small note is needed here: all empty tags (the ones that do not have a specific closing tag, such as <IMG>, <BR> and <HR>) need to have a forward slash just before there greater-than bracket. So, <BR> becomes <BR/>. 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!

  • Read Part 3!

    <?xml version="1.0"?> 
      <xsl:template match="/">
        <xsl:apply-templates />
      <xsl:template match="memo">
    	<title>XML/XSL memo example by Arno Jansen</title>
       	<xsl:apply-templates />
      <xsl:template match="from">
        <xsl:value-of select="."/><br/>
      <xsl:template match="to">
        <xsl:value-of select="."/>
      <xsl:template match="subject">
        <xsl:value-of select="."/>
      <xsl:template match="message">
          <xsl:value-of select="."/>

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article