Jump to content

adding logo xslt problem


Guest tulip2006

Recommended Posts

Guest tulip2006

Hi!I am a new to xsl.I have 5-day weather forecast.I want to add a logo(by clicking logo,it should take you to another web site) right after the table.My logo is in C:\weather.jpg.Can anybody help?thanks in advance.My xslt will look like this.I want to add after weather template.<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates select="dwml" /> </xsl:template> <xsl:template match="dwml"> <xsl:if test="@version != '1.0'"> <div id="error"> Unrecognized DWML version. </div> </xsl:if> <xsl:if test="@version = '1.0'"> <table style="border-collapse: collapse;" border="1" bordercolor="#111111" cellpadding="5" cellspacing="0" width="800px" align="center"> <xsl:apply-templates select="head" /> <xsl:apply-templates select="data" /> </table> </xsl:if> </xsl:template> <xsl:template match="head"> <tr> <td> <xsl:attribute name="colspan">10</xsl:attribute> <a> <xsl:attribute name="target">_blank</xsl:attribute> <xsl:attribute name="href"> <xsl:value-of select="source/credit" /> </xsl:attribute> <img> <xsl:attribute name="border">0</xsl:attribute> <xsl:attribute name="align">right</xsl:attribute> <xsl:attribute name="src"> <xsl:value-of select="source/credit-logo" /> </xsl:attribute> </img> </a> </xsl:template> <xsl:template match="data"> <xsl:apply-templates select="time-layout" /> </xsl:template> <xsl:template match="time-layout"> <xsl:if test="/dwml/data/parameters/*[@time-layout=current()/layout-key]/@type = '12 hour' "> <tr> <xsl:for-each select="/dwml/data/time-layout[position()=3]/start-valid-time[position()]"> <xsl:if test="position()=1"> <xsl:if test="@period-name='Tonight'"> <td> </td> </xsl:if> </xsl:if> <xsl:if test="substring(.,12,8)='06:00:00'"> <td align="center"> <strong> <xsl:value-of select="@period-name" /> </strong> <br/> <xsl:call-template name="conditions-icon"> <xsl:with-param name="position" select="position()"/> </xsl:call-template> <br/> <xsl:call-template name="weather"> <xsl:with-param name="position" select="position()"/> </xsl:call-template> <br/> <xsl:call-template name="temperature"> <xsl:with-param name="temp_type" select="'maximum'"/> <xsl:with-param name="position" select="round(position() div 2)"/> </xsl:call-template> <br/> <xsl:call-template name="POP"> <xsl:with-param name="position" select="position()"/> </xsl:call-template> </td> </xsl:if> </xsl:for-each> </tr> <tr> <xsl:for-each select="/dwml/data/time-layout[position()=3]/start-valid-time[position()]"> <xsl:if test="substring(.,12,8)='18:00:00'"> <td align="center"> <strong> <xsl:value-of select="@period-name" /> </strong> <br/> <xsl:call-template name="conditions-icon"> <xsl:with-param name="position" select="position()"/> </xsl:call-template> <br/> <xsl:call-template name="weather"> <xsl:with-param name="position" select="position()"/> </xsl:call-template> <br/> <xsl:call-template name="temperature"> <xsl:with-param name="temp_type" select="'minimum'"/> <xsl:with-param name="position" select="round(position() div 2)"/> </xsl:call-template> <br/> <xsl:call-template name="POP"> <xsl:with-param name="position" select="position()"/> </xsl:call-template> </td> </xsl:if> </xsl:for-each> </tr> </xsl:if> </xsl:template> <xsl:template name="temperature"> <xsl:param name="temp_type"/> <xsl:param name="position" /> <xsl:if test="/dwml/data/parameters/temperature[@type=$temp_type]/value[position()=$position]/. != ''"> <xsl:if test="$temp_type='maximum'"> High: <xsl:value-of select="/dwml/data/parameters/temperature[@type=$temp_type]/value[position()=$position]/."/>°F </xsl:if> <xsl:if test="$temp_type='minimum'"> Low: <xsl:value-of select="/dwml/data/parameters/temperature[@type=$temp_type]/value[position()=$position]/."/>°F </xsl:if> </xsl:if> </xsl:template> <xsl:template name="POP"> <xsl:param name="position" /> <xsl:if test="/dwml/data/parameters/probability-of-precipitation/value[position()=$position]/. != ''"> <xsl:value-of select="/dwml/data/parameters/probability-of-precipitation/value[position()=$position]/."/>% chance of rain </xsl:if> </xsl:template> <xsl:template name="conditions-icon"> <xsl:param name="position" /> <xsl:if test="/dwml/data/parameters/conditions-icon/icon-link[position()=$position]/. !=''"> <img> <xsl:attribute name="src"> <xsl:if test=".!=''"> <xsl:value-of select="/dwml/data/parameters/conditions-icon/icon-link[position()=$position]/."/> </xsl:if> </xsl:attribute> <xsl:attribute name="align">center</xsl:attribute> </img> </xsl:if> </xsl:template> <xsl:template name="weather"> <xsl:param name="position" /> <xsl:if test="/dwml/data/parameters/weather/weather-conditions[position()=$position]/@weather-summary !=''"> <xsl:value-of select="/dwml/data/parameters/weather/weather-conditions[position()=$position]/@weather-summary"/> </xsl:if> </xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

  • 3 weeks later...

Hi,I'm new at this forum too, but I think they like you to put code between the code brackets (#icon in editor) and furthermore it might be handy to also copy the xml-file with the question.Hope you'll get a useful answer from someone.

Link to comment
Share on other sites

Upload the logo to your web server (for example's sake, I'll use "example.com/weather.jpg") and insert this wherever the table ends:

<a href="http://example.com"><img src="http://example.com/weather.jpg"/></a>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...