?
Solved

Creating link to html Image

Posted on 2011-10-24
3
Medium Priority
?
188 Views
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"/>
        <td>
            <xsl:choose>
                <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="{.}"/>
                        </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>&#160;</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </td>
    </xsl:template>
   
   
   
I wanted to create a link to this image from the album @id attribute

<Album name="Album 1" sno="1" id="tcm:501-638216">
        <Media>
          <Image sno="1">
            <description>The Burj Image-Asit</description>
            <thumbnail>/Preview/staging/sevens/Images/img1.jpg</thumbnail>
            <bigImage>/Preview/staging/sevens/Images/Burj_Khalifa.jpg</bigImage>
            <link></link>
          </Image>
         
          <Image sno="2">
          <description>The Burj Image-Asit</description>
          <thumbnail>/Preview/staging/sevens/Images/Burj_Khalifa.jpg</thumbnail>
          <bigImage>/Preview/staging/sevens/Images/Burj_Khalifa.jpg</bigImage>
          <link></link>
          </Image>
       </Media>    
       
</Album>


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" />
  </xsl:attribute>
<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
<thumbnail>/Preview/staging/sevens/Images/img1.jpg</thumbnail>

Please find my complete xml, xslt attached

Many Thanks
CurrentAlbum.xml
currentAlbum.xsl
0
Comment
Question by:tia_kamakshi
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
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" />
  </xsl:attribute>

0
 

Author Closing Comment

by:tia_kamakshi
ID: 37022212
Many Thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37022531
welcome
0

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