Hyperlinks in XSLT file

  • 15 years ago

    I'm an XML newbie so I hope someone out there can point me in the right direction...


    I have a dataset in which two of the columns are related as follows:  'URLText' is a column that contains the text of a link to display to the user.  'URLLink' is the actual long url.  From that dataset I created an XML document.  I then wrote an XSLT doc to transform that XML document into a very prettily formatted Excel spreadsheet.  The spreadsheet looks fine, all the data from the dataset is in its correct column and etc., but the last column is not working correctly.  It should have only the text, and when the user clicks on it, it should take the user to the correct URL of that text, but instead, it does nothing.  I believe my syntax to take care of this is wrong, but I don't know how else to do it.  Can anyone advise??


    Here is the code to my xslt file:


    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


    xmlns:ss="urn:schemas-microsoft-comffice:spreadsheet">
    <xslutput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <!-- match the root and produce the requisite root Excel Xml stuff -->
    <xsl:template match="/">
       <ss:Workbook>
           <sstyles>
               <sstyle ss:ID="s1" ss:Name="TitleBar">
       <ss:Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:Indent="1"/>
                   <ss:Font ss:FontName="Tahoma" ssize="14" ss:Color="#FFFFFF" ss:Bold="1"/>
       <ss:Interior ss:Color="#8B0000" ss:Pattern="Solid"/>
               </sstyle>
               <sstyle ss:ID="s2" ss:Name="HeaderBar">
       <ss:Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
         <ss:Borders>
               <ss:Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
         </ss:Borders>
         <ss:Font ss:FontName="Tahoma" ssize="10" ss:Color="#FFFFFF" ss:Bold="1"/>
         <ss:Interior ss:Color="#8B0000" ss:Pattern="Solid"/>>
               </sstyle>
               <sstyle ss:ID="s3" ss:Name="Contents">
         <ss:Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:WrapText="1"/>
         <ss:Borders>
             <ss:Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
         </ss:Borders>
         <ss:Font ss:FontName="Tahoma" ssize="10" ss:Color="#000000"/>
         <ss:Interior ss:Color="#D3D3D3" ss:Pattern="Solid"/>
               </sstyle>
               <sstyle ss:ID="s4" ss:Name="DateTime">
         <ss:Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:WrapText="1"/>
         <ss:Borders>
               <ss:Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
             <ss:Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
             <ss:Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
         </ss:Borders>
         <ss:Font ss:FontName="Tahoma" ssize="10" ss:Color="#000000"/>
         <ss:Interior ss:Color="#D3D3D3" ss:Pattern="Solid"/>
         <ss:NumberFormat ss:Format="[$-409]m/d/yy\ h:mm\ AM/PM;@"/>
               </sstyle>
               <sstyle ss:ID="s5" ss:Name="Duration">
         <ss:Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:WrapText="1"/>
       <ss:Borders>
           <ss:Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
         </ss:Borders>
         <ss:Font ss:FontName="Tahoma" ssize="10" ss:Color="#000000"/>
         <ss:Interior ss:Color="#D3D3D3" ss:Pattern="Solid"/>
         <ss:NumberFormat ss:Format="Fixed"/>
               </sstyle>
               <sstyle ss:ID="s6" ss:Name="Hyperlinks">
         <ss:Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:WrapText="1"/>
         <ss:Borders>
               <ss:Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
         </ss:Borders>
         <ss:Font ss:FontName="Tahoma" ssize="10" ss:Color="#000000" ss:Underline="Single"/>
         <ss:Interior ss:Color="#D3D3D3" ss:Pattern="Solid"/>
               </sstyle>
               <sstyle ss:ID="s7" ss:Name="Number">
         <ss:Alignment ss:Horizontal="Right" ss:Vertical="Bottom" ss:WrapText="1"/>
         <ss:Borders>
             <ss:Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
               <ss:Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1" ss:Color="#000000"/>
         </ss:Borders>
         <ss:Font ss:FontName="Tahoma" ssize="10" ss:Color="#000000"/>
         <ss:Interior ss:Color="#D3D3D3" ss:Pattern="Solid"/>
         <ss:NumberFormat ss:Format="0"/>
               </sstyle>
           </sstyles>
           <ss:Worksheet ss:Name="Customer Management List">
               <xsl:apply-templates />
           </ss:Worksheet>
       </ss:Workbook>
    </xsl:template>
    <!-- match the PhoneBook element and produce the table and header row -->
    <xsl:template match="ClientSupportLog">
       <ss:Table>
           <ss:Column ss:Width="127"/>
           <ss:Column ss:Width="135"/>
           <ss:Column ss:Width="117"/>
           <ss:Column ss:Width="119"/>
           <ss:Column ss:Width="82"/>
           <ss:Column ss:Width="110"/>
           <ss:Column ss:Width="110"/>
           <ss:Column ss:Width="70"/>
           <ss:Column ss:Width="271"/>
           <ss:Column ss:Width="258"/>
           <ss:Column ss:Width="308"/>
           <ss:Row  ss:AutoFitHeight="0" ss:Height="18" sstyleID="s1">
               <ss:Cell>
                   <ssata ss:Type="String">CLIENT SUPPORT MANAGEMENT</ssata>
               </ss:Cell>
           </ss:Row>
           <ss:Row ss:AutoFitHeight="0" ss:Height="25.5" sstyleID="s2">
               <ss:Cell>
                   <ssata ss:Type="String">PartnerID</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Partner Name</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Subject</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Contact Name</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">IP Support Contact</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Date Time Started</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Date Time Ended</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Duration</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Emails and IMs</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Scripts and Fixes</ssata>
               </ss:Cell>
               <ss:Cell>
                   <ssata ss:Type="String">Comments</ssata>
               </ss:Cell>
           </ss:Row>
           <xsl:apply-templates />
       </ss:Table>
    </xsl:template>
    <!-- match an entry and produce a whole row of data from it -->
    <xsl:template match="SupportIncident">
       <ss:Row sstyleID="s3">
           <ss:Cell sstyleID="s7">
               <ssata ss:Type="Number">
                   <xsl:value-of select="PartnerID" />
               </ssata>
           </ss:Cell>
           <ss:Cell>
               <ssata ss:Type="String">
                   <xsl:value-of select="Partner
    Name" />
               </ssata>
           </ss:Cell>
           <ss:Cell>
               <ssata ss:Type="String">
                   <xsl:value-of select="SupportSubject" />
               </ssata>
           </ss:Cell>
           <ss:Cell>
               <ssata ss:Type="String">
                   <xsl:value-of select="Contact
    Name" />
               </ssata>
           </ss:Cell>
           <ss:Cell>
               <ssata ss:Type="String">
                   <xsl:value-of select="IPSupportContact" />
               </ssata>
           </ss:Cell>
           <ss:Cell sstyleID="s4">
               <ssata ss:Type="String">
                   <xsl:value-of select="DateTimeStarted" />
               </ssata>
           </ss:Cell>
           <ss:Cell sstyleID="s4">
               <ssata ss:Type="String">
                   <xsl:value-of select="DateTimeEnded" />
               </ssata>
           </ss:Cell>
           <ss:Cell sstyleID="s5" ss:Formula="=(DAY(RC[-1]-RC[-2])*24)+(HOUR(RC[-1]-RC[-2]))+(MINUTE(RC[-1]-RC[-2])/60)">
               <ssata ss:Type="Number">
                   <xsl:value-of select="Duration" />
               </ssata>
           </ss:Cell>
           <ss:Cell sstyleID="s6" ss:HRef="@URLLink">
               <ssata ss:Type="String">
                   <xsl:value-of select="URL
    Text" />
               </ssata>
           </ss:Cell>
            <ss:Cell>
               <ssata ss:Type="String">
                   <xsl:value-of select="Comments" />
               </ssata>
           </ss:Cell>
       </ss:Row>
    </xsl:template>
    </xsl:stylesheet>

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone” - Bjarne Stroustrup