Creating link to html Image

Posted on 2011-10-24
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
    LVL 60

    Accepted Solution

    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

    Many Thanks
    LVL 60

    Expert Comment

    by:Geert Bormans

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    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…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    746 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

    18 Experts available now in Live!

    Get 1:1 Help Now