Creating link to html Image

Posted on 2011-10-24
Medium Priority
Last Modified: 2013-11-18
Hi Experts,

In xslt below, It is creating html img tag from attached xml file

<xsl:template name="output-album">
        <xsl:param name="sno"/>
                <xsl:when test="../Album[@sno = $sno]">
                    <xsl:for-each select="(../Album[@sno = $sno]/Media/*[@sno = 1]/thumbnail | ../Album[@sno = $sno]/Media/*[@sno = 1]/thumbMedia)[1]">
                            <img src="{.}"/>
I wanted to create a link to this image from the album @id attribute

<Album name="Album 1" sno="1" id="tcm:501-638216">
          <Image sno="1">
            <description>The Burj Image-Asit</description>
          <Image sno="2">
          <description>The Burj Image-Asit</description>

I tried various ways, but not sure what I am doing wrong, I am not able to pick id. I wrote

<xsl:attribute name="href">
    Album.aspx?id=<xsl:value-of select="Album/@id" />
<img src="{.}"/>

My link to image tag is always coming blank. Please help me picking the

id attribute from just above Album node.

In above example id from below node

<Album name="Album 1" sno="1" id="tcm:501-638216">.

It is picking image src from node

Please find my complete xml, xslt attached

Many Thanks
Question by:tia_kamakshi
  • 2
LVL 60

Accepted Solution

Geert Bormans earned 2000 total points
ID: 37020740
do you want your image to be clickable?

you are not in teh scope of teh parent of Album, so your href can not work.
You need to go look for the ancestor::Album since you are at the thumbnail level already

<xsl:attribute name="href">
    Album.aspx?id=<xsl:value-of select="ancestor::Album/@id" />


Author Closing Comment

ID: 37022212
Many Thanks
LVL 60

Expert Comment

by:Geert Bormans
ID: 37022531

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

850 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