Hyperlink Email

Here should go questions about transforming XML with XSLT and FOP.
shansen
Posts: 1
Joined: Wed Oct 26, 2011 11:35 pm

Hyperlink Email

Post by shansen »

I am a definite noob when it comes to XSL and am trying to assist a co-worker in gaining functionality with her database. My code looks like this:

<td align="left">

<xsl:for-each select="fmrs:resultset/fmrs:record/fmrs:field[@name='Contacts::email']/fmrs:data">
<xsl:if test="position() != 1"><br/></xsl:if>
<xsl:value-of disable-output-escaping="yes" select="fmxslt:break_encode(.)"/>
<xsl:if test=". = ''">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</xsl:if>
</xsl:for-each>
</td>

I'm trying to make it where the email address that appears in the browser becomes hyperlinked. The email addresses are dynamic and not static. Any help would be greatly appreciated. Thanks!
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Hyperlink Email

Post by adrian »

Hello,

Assign the current node(the email address) to a variable and add an anchor with the value from this variable(<a href="mailto:email" class="link">email</a>). Can be written in XSLT as:

Code: Select all

<xsl:variable name="email" select="."/>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>mailto:</xsl:text>
<xsl:value-of select="$email"/>
</xsl:attribute>
<xsl:value-of select="$email"/>
</xsl:element>
If the current node is not the email address, simply modify the expression in the select from the variable with the appropriate one.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply