[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: trouble creating a link (style suggestions)

Subject: Re: trouble creating a link (style suggestions)
From: Dan Morrison <dman@xxxxxxxx>
Date: Tue, 30 May 2000 15:18:11 +1200
xsl link style
Wayne Davis wrote:
> 
> Here's what works...(also posting the code I'm using to create a web based
> link, in the event that someone else finds it useful - _someone_ else out
> there must be as green as I am with this stuff <g>)

Good example, but (with your forgiveness) I can't resist 'tidying' it. 
I make some assumptions about EMAIL and WEB being exclusive, and the
only options (which may not be the case). The select="." may have
side-effects in other context.

<li>
<a>
  <font face="Arial" size="2" color="aqua">
    <xsl:attribute name="href">
      <xsl:if test="EMAIL[.!='']">
        mailto:<xsl:value-of select="EMAIL"/>
      </xsl:if>
      <xsl:if test="WEB[.!='']">
        <xsl:value-of select="WEB"/>
      </xsl:if>
    </xsl:attribute>
    <xsl:value-of select="."/>
  </font>
</a>
</li>


2 Points.
Your example, while good for an example and clarity, contains repetition
which can be avoided. Two identical 'font' definitions especially could
trip up later maintainence.

I think it's better html if the "a" is inside the "li". NS in particular
/may/ link strangely.

Also, while I've not tested it thoughoughly, I usually get away with
just test="EMAIL". I'm unsure of the legality of this tho'.

Apologies, as this is only personal, stylistic opinion. Sometimes I pay
so much attention to 'elegant' I forget about 'practical'. ( But my Perl
one-liners are fab  ;-) )

OTOH, you may want to move in the other direction and split it out into
separate <xsl:template match="EMAIL">... chunks. Much more versatile. 
This is actually how I do it in practice, as I have freetext content
which may include links at any position...


I'll get down off my high-horse now...



thud.


.dan.





Snippet from one of my template libraries...

<!--
################## Generic default template ####################
##                       'EMAIL'                              ##
##  Turns a 'EMAIL' into an 'mailto' tag.                     ##
-->
  <xsl:template match="EMAIL">
  <a><xsl:attribute name="href">mailto:<xsl:value-of select="."
/></xsl:attribute><xsl:value-of select="." /></a>
  </xsl:template>
<!--
##                                                            ##
################################################################
 -->


-- 
:=====================:====================:
: Dan Morrison        : The Web Limited    :
:  http://here.is/dan :  http://web.co.nz  :
:  dman@xxxxxxxx      :  danm@xxxxxxxxx    :
:  04 384 1472        :  04 495 8250       :
:  025 207 1140       :                    :
:.....................:....................:
: If ignorance is bliss, why aren't more people happy?
:.........................................:


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.