Solved

How do I add a logo in this XSL statement?

Posted on 2008-10-24
1
462 Views
Last Modified: 2013-11-18
New to XSLT stuff. Trying to add a logo to the attached code snippet in the section starting with:

  <!--Uncomment and modify the following to insert a company logo-->
                        <!--<xsl:if test="$isOther=0">
                      <xsl:element name="img">
                        <xsl:attribute name="style">
                          <xsl:text>width: 5em; padding-right: 1em</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="src">
                          <xsl:text>file://localhost/C:\Program Files\commtest-colour.jpg</xsl:text>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:if>-->

I know its simple, but I am pressed for time.  Thanks!



<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes" encoding="utf-16"  version="1.0" standalone="yes"/>
 
  <!--Microsoft XSLT generators-->
  <xsl:variable name="isMicrosoft" select="boolean(system-property('xsl:vendor') ='Microsoft')"/>
  <!--Mozilla XSLT generators (i.e. Firefox)-->
  <xsl:variable name="isTransformiix" select="boolean(system-property('xsl:vendor') ='Transformiix')"/>
  <!--Other XSLT generators (Opera, Safari...)-->
  <xsl:variable name="isOther" select="boolean(not ($isMicrosoft or $isTransformiix))"/>
 
  <!--===============================================-->
  <!--= Section: DisplayImage                       =-->
  <!--= Purpose: Displays the reports images        =-->
  <!--= Params: None                                =-->
  <!--= Returns: N/A                                =-->
  <!--===============================================-->
  <xsl:template xmlns="http://www.w3.org/1999/xhtml" match="field[@isEmpty='False' and @isImage='True']/item">
    <!--<xsl:element name="div">-->
    <!--<xsl:attribute name="style">
        <xsl:text>padding-top:1em; padding-left:0.5em; padding-right:0.5em; </xsl:text>
      </xsl:attribute>-->
    <xsl:element name="img">
      <xsl:attribute name="style">
        <xsl:text>padding-top:1em; padding-left:0.5em; padding-right:0.5em; </xsl:text>
      </xsl:attribute>
      <xsl:attribute name="src">
        <xsl:value-of select ="."/>
      </xsl:attribute>
    </xsl:element>
    <!--</xsl:element>-->
  </xsl:template>
 
  <!--===============================================-->
  <!--= Section: TextBreak                          =-->
  <!--= Purpose: Replaces line with html breaks     =-->
  <!--= Params: None                                =-->
  <!--= Returns: N/A                                =-->
  <!--===============================================-->
  <xsl:template xmlns="http://www.w3.org/1999/xhtml" name="break">
    <xsl:param name="text" select="."/>
    <xsl:choose>
      <xsl:when test="contains($text, '&#xA;')">
        <xsl:value-of select="substring-before($text, '&#xA;')"/>
        <xsl:element name="br"/>
        <xsl:call-template name="break">
          <xsl:with-param name="text" select="substring-after($text,'&#xA;')"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
 
  <!--===============================================-->
  <!--= Section: DisplayReport                      =-->
  <!--= Purpose: Displays each report               =-->
  <!--= Params: None                                =-->
  <!--= Returns: N/A                                =-->
  <!--===============================================-->
  <xsl:key name="reports-by-folder" match="report" use="field[@name='ProfileID']/item" />
  <xsl:template match="report-list" xmlns="http://www.w3.org/1999/xhtml">
    <xsl:element name="html">
      <xsl:element name="head">
        <xsl:element name="title">
          <xsl:text>Machine Assessment Report</xsl:text>
        </xsl:element>
      </xsl:element>
      <xsl:element name="body">
 
        <!--Display Reports grouped by profile name-->
        <xsl:for-each select="report[count(. | key('reports-by-folder', field[@name='ProfileID']/item)[1]) = 1]">
          <xsl:sort data-type="text"  order="ascending" select ="field[@name='Location']/item"/>
          <xsl:element name="div">
            <xsl:attribute name="style">
              <xsl:text>page-break-after:always</xsl:text>
            </xsl:attribute>
            <xsl:for-each select="key('reports-by-folder', field[@name='ProfileID']/item)">
              <xsl:sort data-type="number" order ="descending" select="field[@name='Priority']/item"/>
              <xsl:sort data-type="text" order="ascending" select ="field[@name='Machine']/item"/>
              <xsl:variable name="priority" select="field[@name='Priority']/item"/>
              <xsl:variable name="priorityName" select="field[@name='Priority']/enum-list/enum[@value=$priority]"/>
              <!--Display Reports greater than a certain priority (currently disabled)-->
              <xsl:if test="$priority > -1">
                <xsl:element name="div">
                  <!--Include a page break after the first report (used for printing)-->
                  <xsl:if test="position()!=1">
                    <xsl:attribute name="style">
                      <xsl:text>page-break-before:always </xsl:text>
                    </xsl:attribute>
                  </xsl:if>
                  <!--Display the header-->
                  <xsl:element name="table">
                    <xsl:attribute name="style">
                      <xsl:text>width: 100%</xsl:text>
                    </xsl:attribute>
                    <xsl:element name="thead">
                      <xsl:element name="th">
                        <xsl:attribute name="style">
                          <xsl:text>text-align: left; font-style: italic</xsl:text>
                        </xsl:attribute>
 
                        <!--Uncomment and modify the following to insert a company logo-->
                        <!--<xsl:if test="$isOther=0">
                      <xsl:element name="img">
                        <xsl:attribute name="style">
                          <xsl:text>width: 5em; padding-right: 1em</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="src">
                          <xsl:text>file://localhost/C:\Program Files\commtest-colour.jpg</xsl:text>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:if>-->
 
                        <xsl:attribute name="colspan">
                          <xsl:text>2</xsl:text>
                        </xsl:attribute>
                        <xsl:element name="b">
                          <xsl:text>Machine Assessment Report</xsl:text>
                        </xsl:element>
                      </xsl:element>
                    </xsl:element>
                  </xsl:element>
                  <xsl:element name="hr">
                    <xsl:attribute name="style">
                      <xsl:text>color: Red</xsl:text>
                    </xsl:attribute>
                  </xsl:element>
                  <!--Display the report data-->
                  <xsl:element name="table">
                    <xsl:attribute name="style">
                      <xsl:text>width: 100%</xsl:text>
                    </xsl:attribute>
                    <!--Display the machine's folder, the assigned priority and the analyst name-->
                    <xsl:element name="tr">
                      <!--Display the machine's folder-->
                      <xsl:element name="td">
                        <xsl:attribute name="style">
                          <xsl:text>font-size: medium; font-weight: bold;text-align: right;  width: 8em; padding-right:1em</xsl:text>
                        </xsl:attribute>
                        <xsl:text>Folder</xsl:text>
                      </xsl:element>
                      <xsl:element name="td">
                        <xsl:attribute name="style">
                          <xsl:text>font-size: medium; font-weight: bold; width:100%</xsl:text>
                        </xsl:attribute>
                        <xsl:value-of select="substring(field[@name='Location']/item,1)"/>
                      </xsl:element>
                      <!--Display the the priority and the analyst name-->
                      <xsl:element name="td">
                        <xsl:attribute name="valign">
                          <xsl:text>top</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="rowspan">
                          <xsl:text>5</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="style">
                          <xsl:text>font-size: medium; font-weight: bold; width: 10em</xsl:text>
                        </xsl:attribute>
                        <!--Display the priority-->
                        <xsl:element name="div">
                          <xsl:attribute name="style">
                            <xsl:text>padding-bottom: 10px</xsl:text>
                          </xsl:attribute>
                          <xsl:text>Priority</xsl:text>
                        </xsl:element>
                        <xsl:element name="div">
                          <xsl:choose>
                            <xsl:when test="$priority=0">
                              <xsl:attribute name="style">
                                <xsl:text>white-space:nowrap;  border-style: solid; border-width: thin; background-color: LightGrey; text-align: center</xsl:text>
                              </xsl:attribute>
                            </xsl:when>
                            <xsl:when test="$priority=1">
                              <xsl:attribute name="style">
                                <xsl:text>white-space:nowrap; border-style: solid; border-width: thin; background-color: #B2FF64; text-align: center</xsl:text>
                              </xsl:attribute>
                            </xsl:when>
                            <xsl:when test="$priority=2">
                              <xsl:attribute name="style">
                                <xsl:text>white-space:nowrap; border-style: solid; border-width: thin; background-color: #FFFE64; text-align: center</xsl:text>
                              </xsl:attribute>
                            </xsl:when>
                            <xsl:when test="$priority=3">
                              <xsl:attribute name="style">
                                <xsl:text>white-space:nowrap; border-style: solid; border-width: thin; background-color: #FFB164; text-align: center</xsl:text>
                              </xsl:attribute>
                            </xsl:when>
                            <xsl:when test="$priority=4">
                              <xsl:attribute name="style">
                                <xsl:text>white-space:nowrap; border-style: solid; border-width: thin; background-color: #FF6464; text-align: center</xsl:text>
                              </xsl:attribute>
                            </xsl:when>
                            <xsl:when test="$priority=5">
                              <xsl:attribute name="style">
                                <xsl:text>white-space:nowrap; border-style: solid; border-width: thin; background-color: #64FFFF; text-align: center</xsl:text>
                              </xsl:attribute>
                            </xsl:when>
                          </xsl:choose>
                          <xsl:value-of select ="$priorityName"/>
                        </xsl:element>
                        <!--Display the analysts name (if it exists)-->
                        <xsl:if test="field[@name='AnalystName'and @isEmpty='False']">
                          <xsl:element name="div">
                            <xsl:attribute name="style">
                              <xsl:text>margin-top: 1em;font-size: medium</xsl:text>
                            </xsl:attribute>
                            <xsl:text>Analyst</xsl:text>
                            <xsl:element name="br"/>
                            <xsl:element name="div">
                              <xsl:attribute name="style">
                                <xsl:text>white-space:nowrap; font-size: smaller; font-weight: lighter</xsl:text>
                              </xsl:attribute>
                              <xsl:value-of select="substring(field[@name='AnalystName']/item,1)"/>
                            </xsl:element>
                            <xsl:element name="br"/>
                          </xsl:element>
                        </xsl:if>
                      </xsl:element>
                    </xsl:element>
                    <!--Display the machine name-->
                    <xsl:element name="tr">
                      <xsl:element name="td">
                        <xsl:attribute name="style">
                          <xsl:text>font-size: medium;text-align: right; font-weight: bold; padding-right:1em </xsl:text>
                        </xsl:attribute>
                        <xsl:text>Machine</xsl:text>
                      </xsl:element>
                      <xsl:element name="td">
                        <xsl:attribute name="style">
                          <xsl:text>font-size: medium; font-weight: bold</xsl:text>
                        </xsl:attribute>
                        <xsl:value-of select="substring(field[@name='Machine']/item,1)"/>
                      </xsl:element>
                    </xsl:element>
                    <!--Display the report date-->
                    <xsl:element name="tr">
                      <xsl:element name="td">
                        <xsl:attribute name="style">
                          <xsl:text> white-space:nowrap; font-weight: bold; text-align: right; padding-right:1em </xsl:text>
                        </xsl:attribute>
                        <xsl:text>Report Date</xsl:text>
                      </xsl:element>
                      <xsl:element name="td">
                        <xsl:variable name="rawDate" select ="translate(substring-before(field[@name='SurveyDate']/item,'-'),'/','')"/>
                        <xsl:variable name ="Year" select ="substring($rawDate,1,4)"/>
                        <xsl:variable name ="Day" select ="substring($rawDate,7,2)"/>
                        <xsl:variable name ="Month" select ="number(substring($rawDate,5,2))"/>
                        <xsl:variable name ="shortMonth">
                          <xsl:choose>
                            <xsl:when test ="$Month=01">Jan</xsl:when>
                            <xsl:when test ="$Month=02">Feb</xsl:when>
                            <xsl:when test ="$Month=03">Mar</xsl:when>
                            <xsl:when test ="$Month=04">Apr</xsl:when>
                            <xsl:when test ="$Month=05">May</xsl:when>
                            <xsl:when test ="$Month=06">Jun</xsl:when>
                            <xsl:when test ="$Month=07">Jul</xsl:when>
                            <xsl:when test ="$Month=08">Aug</xsl:when>
                            <xsl:when test ="$Month=09">Sep</xsl:when>
                            <xsl:when test ="$Month=10">Oct</xsl:when>
                            <xsl:when test ="$Month=11">Nov</xsl:when>
                            <xsl:when test ="$Month=12">Dec</xsl:when>
                          </xsl:choose>
                        </xsl:variable>
                        <xsl:value-of select="$Day"/>
                        <xsl:text>-</xsl:text>
                        <xsl:value-of select="$shortMonth"/>
                        <xsl:text>-</xsl:text>
                        <xsl:value-of select="$Year"/>
                      </xsl:element>
                    </xsl:element>
                    <!--Display the fault type-->
                    <xsl:element name="tr">
                      <xsl:element name="td">
                        <xsl:attribute name="style">
                          <xsl:text> font-weight: bold; text-align: right; padding-right:1em</xsl:text>
                        </xsl:attribute>
                        <xsl:if test="field[@name='Fault'and @isEmpty='False']">
                          <xsl:text>Fault</xsl:text>
                        </xsl:if>
                      </xsl:element>
                      <xsl:element name="td">
                        <xsl:value-of select="substring(field[@name='Fault']/item,1)"/>
                      </xsl:element>
                    </xsl:element>
                    <!--Display the fault location-->
                    <xsl:element name="tr">
                      <xsl:element name="td">
                        <xsl:attribute name="style">
                          <xsl:text> font-weight: bold; text-align: right; padding-right:1em</xsl:text>
                        </xsl:attribute>
                        <xsl:if test="field[@name='FaultLocation'and @isEmpty='False']">
                          <xsl:text>Location</xsl:text>
                        </xsl:if>
                      </xsl:element>
                      <xsl:element name="td">
                        <xsl:value-of select="substring(field[@name='FaultLocation']/item,1)"/>
                        <xsl:element name="br"/>
                      </xsl:element>
                    </xsl:element>
                    <!--Display the findings-->
                    <xsl:if test="field[@name='Findings'and @isEmpty='False']">
                      <xsl:element name="tr">
                        <xsl:element name="td">
                          <xsl:attribute name="style">
                            <xsl:text>font-weight: bold;text-align: right; padding-right:1em; vertical-align: top</xsl:text>
                          </xsl:attribute>
                          <xsl:text>Findings</xsl:text>
                        </xsl:element>
                        <xsl:element name="td">
                          <xsl:attribute name="colspan">
                            <xsl:text>2</xsl:text>
                          </xsl:attribute>
                          <xsl:attribute name="style">
                            <xsl:text>font-weight: normal</xsl:text>
                          </xsl:attribute>
                          <xsl:call-template name="break" >
                            <xsl:with-param name="text" select="substring(field[@name='Findings']/item,1)"/>
                          </xsl:call-template>
                        </xsl:element>
                      </xsl:element>
                    </xsl:if>
                    <!--Display the recommendations-->
                    <xsl:if test="field[@name='Recomendations'and @isEmpty='False']">
                      <xsl:element name="tr">
                        <xsl:element name="td">
                          <xsl:attribute name="style">
                            <xsl:text>padding-top:1em; font-weight: bold;text-align: right;padding-right:1em; vertical-align: top</xsl:text>
                          </xsl:attribute>
                          <xsl:text>Recommendation</xsl:text>
                        </xsl:element>
                        <xsl:element name="td">
                          <xsl:attribute name="colspan">
                            <xsl:text>2</xsl:text>
                          </xsl:attribute>
                          <xsl:attribute name="style">
                            <xsl:text>padding-top:1em; font-weight: normal</xsl:text>
                          </xsl:attribute>
                          <xsl:call-template name="break" >
                            <xsl:with-param name="text" select="substring(field[@name='Recomendations']/item,1)"/>
                          </xsl:call-template>
                        </xsl:element>
                      </xsl:element>
                    </xsl:if>
                    <!--Display the image notes-->
                    <xsl:if test="field[@name='PlotSummary'and @isEmpty='False']">
                      <xsl:element name="tr">
                        <xsl:element name="td">
                          <xsl:attribute name="style">
                            <xsl:text>padding-top:1em; font-weight: bold;text-align: right;padding-right:1em; vertical-align: top</xsl:text>
                          </xsl:attribute>
                          <xsl:text>Image Notes</xsl:text>
                        </xsl:element>
                        <xsl:element name="td">
                          <xsl:attribute name="colspan">
                            <xsl:text>2</xsl:text>
                          </xsl:attribute>
                          <xsl:attribute name="style">
                            <xsl:text>padding-top:1em; font-weight: normal</xsl:text>
                          </xsl:attribute>
                          <xsl:call-template name="break" >
                            <xsl:with-param name="text" select="substring(field[@name='PlotSummary']/item,1)"/>
                          </xsl:call-template>
                        </xsl:element>
                      </xsl:element>
                    </xsl:if>
                  </xsl:element>
                  <!--Display the images-->
                  <xsl:if test="field[@name='Images' and @isEmpty='False']">
                    <xsl:element name="div">
                      <xsl:attribute name="style">
                        <xsl:text>text-align:center</xsl:text>
                      </xsl:attribute>
                      <xsl:apply-templates select="field[@name='Images']"/>
                    </xsl:element>
                  </xsl:if>
                </xsl:element>
              </xsl:if>
            </xsl:for-each>
          </xsl:element>
        </xsl:for-each>
      </xsl:element>
    </xsl:element>
  </xsl:template>
 
</xsl:stylesheet>

Open in new window

0
Comment
Question by:jvalescu
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 22800251
change that piece into

<!--Uncomment and modify the following to insert a company logo-->
                        <xsl:if test="$isOther=0">
                      <xsl:element name="img">
                        <xsl:attribute name="style">
                          <xsl:text>width: 5em; padding-right: 1em</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="src">
                          <xsl:text>file://localhost/C:\Program Files\commtest-colour.jpg</xsl:text>
                        </xsl:attribute>
                      </xsl:element>
                    </xsl:if>

(this means dropping the comment indicators <!-- and -->
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bets framework/boilerplate to follow when creating a new Wordpress plugin 3 39
Google adds suggestions 3 62
ColdFusion Rereplace 3 78
Select distinct 25 97
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now