RE: Preloading Images

Subject: RE: Preloading Images
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 18 Jul 2000 09:20:51 +0100
> Given the XML:
> 
> <?xml version="1.0"?>
> <LeftNavList>
> 	<PreLoadImage>images/image1</PreLoadImage>
> 	<PreLoadImage>images/image2</PreLoadImage>
> 	<PreLoadImage>images/image3</PreLoadImage>
> </LeftNavList>
> 
> I would like to generate the following html snippet:
> 
> <body bgcolor="#ffffff" onLoad="PreloadImages
> ('images/image1.gif','images/image2.gif','images/image3.gif');">
> 

Someone gave you a simple solution by redefining the problem, but for the
record, it's not difficult to get the output you want. Write:

<xsl:template match="LeftNavList">
  <body bgcolor="#ffffff">
    <xsl:attribute name="onLoad">PreloadImages(
       <xsl:for-each select="PreLoadImage">
         '<xsl:value-of select=".">.gif'
         <xsl:if test="position()!=last()">,</xsl:if>
       </xsl:for-each>);</xsl:attribute>
  </body>
</xsl:template>

You may want to adjust that a bit for whitespace.

Mike Kay


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


Current Thread