[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: Creating Hyperlinks using XSL and XML


Subject: Re: Creating Hyperlinks using XSL and XML
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Mon, 05 Apr 1999 23:47:53 -0400

At 06:44 PM 4/5/99 -0700, Duane Nickull wrote:
>>After reading all the other people complaining because their browser
>does not validate,  I feel like I got the NAZI Browser - it picks
>everything apart, including stuff that displays on other people fine. 

I've almost -- not 100%, but almost -- given up using IE5/final rel. for
anything but experiments in trying to grok what MS is up to. It comes
really close to the WD spec in so many ways, which makes it tempting to
use, but departs in just enough to frustrate the bejeezus out of me. (The
one thing that drives me absolutely berserk occurs when trying to debug a
stylesheet; frequently, for no reason that I can discern, IE5 simply
displays a blank page. "Hmm, I wonder what's wrong?" I think, and pull down
the View Source menu selection. ***But it doesn't show you the result tree
-- it shows you the SOURCE TREE.*** Which never changes, no matter *what*
you do to the XSL.)

What I did was (a) cleaned up the XML a bit, including an added "wrapper"
root element; (b) created an XSL document to convert the doc into HTML 4.0;
and (c) (the crucial step) ran it through XT to actually produce the .html
file. XT behaves like I expect it to 99.9% of the time (and the .1% is
generally because my expectation needs adjusting :).

Results:

(a) "duane.xml": 
   <?xml:stylesheet type="text/xsl" href="duane.xsl" ?>
   <doc>
   <brown_nose>
   The <link url="http://www.mulberrytech.com/xsl/xsl-list/">XSL 
   List</link> is a great
   place to ask questions about XSL.
   </brown_nose>
   </doc>

(b) "duane.xsl":
   <xsl:stylesheet 
      xmlns:xsl="http://www.w3.org/TR/WD-xsl"
	xmlns="http://www.w3.org/TR/REC-html40" 
	result-ns="">
		
   <xsl:template match="/">
	<html>
	<head>
	<title>Duane's Doc</title>
	<style type="text/css">
	* {font-family: Verdana, Helvetica, sans-serif;}
	</style>
	</head>
	<body>
	   <xsl:apply-templates/>
	</body>
	</html>
   </xsl:template>
	
   <xsl:template match="brown_nose">
	<p><xsl:apply-templates/></p>
   </xsl:template>

   <xsl:template match="brown_nose/link">
	<a href="{@url}"><xsl:value-of select="."/></a>
   </xsl:template>
   </xsl:stylesheet>

That last template rule (for the link element) is actually one of several
that produces the same result.

(c) "duane.html":
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
   <html>
   <head>
   <title>Duane's Doc</title>
   <style type="text/css">
	* {font-family: Verdana, Helvetica, sans-serif;}
	</style>
   </head>
   <body>
   <p>
   The <a href="http://www.mulberrytech.com/xsl/xsl-list/">XSL 
   List</a> is a great place to ask questions about XSL.
   </p>
   </body>
   </html>

Again, this is exactly what I wanted -- but IE5 wouldn't give it to me. (If
you try viewing "duane.xml" directly, with no xml:stylesheet PI, it
displays in the customary expandable/collapsible tree. With the stylesheet
PI, it displays as a blank page.)

A great site for seeing how to use XSL to generate HTML from XML is at:
	http://www.xmlsoftware.com/articles/xsl-by-example.html
Very cool and very plainly stated. (Thanks again to James Tauber.)

HTH,
John
==========================================================
John E. Simpson            | The secret of eternal youth
simpson@xxxxxxxxxxx        | is arrested development.
http://www.flixml.org      |  -- Alice Roosevelt Longworth


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords