Jump to content



Recommended Posts

This may sound foolish but I have to ask.....Here is an simple example of what I'm trying to do.

XML<familyinfo>	<image>some_image.jpg</image>                <imagelink>some_page.xml</imagelink><--- (This has the address I wish to use for the link)                <description>some information</description></familyinfo>

XSLT<xsl:for-each select="familyinfo">                <xsl:element name="image">                     <xsl:attribute name="src">                          <xsl:value-of select="image" /> <--- (When image is clicked it goes to the link address above)                     </xsl:attribute>                </xsl:element>                   <xsl:element name="a"> <--- (This ends up linking description and needs to be removed)                         <xsl:attribute name="href"> <--- (Needs to be removed)                          <xsl:value-of select="imagelink" /> <--- (Needs to be removed)                     </xsl:attribute> <--- (Needs to be removed)                </xsl:element>  <--- (Needs to be removed)                <xsl:element name="description">                         <xsl:value-of select="description"/>                </xsl:element></xsl:for-each>

The image works regardless if I use img, or image as the element, but how do I get the link to work by clicking the image?Any help would be appreciated.

Link to comment
Share on other sites

Let's remember how we do it in XHTML, shall we?

<a href="some_page.xml">	<img src="some_image.jpg"/>	some information</a>

This is where we're trying to go, right? If so, than this simple stylesheet should do it perfectly:

<xsl:for-each select="familyinfo"><a href="{imagelink}">	<img src="{image}"/>	<xsl:value-of select="description"/></a></xsl:for-each>

(in practice, I'd use a template instead, but for now, I've used for-each for simplicity's sake)

Link to comment
Share on other sites

You are the Man!, or Women! BOEN ROBOT.
The man... please. I'm a man. I'd hate to be confused with a woman, or worse :) .
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...