[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Combining call-template with attribute value temp
Subject: Re: Combining call-template with attribute value templates
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 09 Feb 2005 14:34:39 -0500
|
Frans,
Of course, "clean" and "beautiful" are difficult to define in a way that
doesn't come down to something subjective. (But see Christopher Alexander's
recent work. :-)
In any case, short of XSLT 2.0 I'd probably do:
<xsl:variable name="resultURI">
<xsl:text>http://example.com/</xsl:text>
<xsl:call-template name="fullName" />
</xsl:variable>
<a href="{str:encode-uri($resultURI))}" >
<xsl:value-of select="r:testee/r:name"/>
</a>
which is almost what you had.
Cheers,
Wendell
At 02:10 PM 2/9/2005, you wrote:
I find the following code XSLT code clumsy:
<xsl:variable name="resultPath">
<xsl:call-template name="fullName" />
</xsl:variable>
<a href="{str:encode-uri(concat( 'http://example.com/',
$resultPath, r:testee/r:name ))}" >
<xsl:value-of select="r:testee/r:name"/>
</a>
In other words, I dynamically create the href attribute with an attribute
value template, which among other things contains the return value of the
fullName template.
What I found clumsy, is that the only reason I use the xsl:variable is that I
can't squeeze in the template call into the attr val template. Or how is this
possible?
Another way could be to use an xsl:attribute construct:
<a>
<xsl:attribute name="href">
http://example.com/
<xsl:call-template name="fullName" />
<xsl:value-of select="r:testee/r:name" />
</xsl:attribute>
</a>
I find it a /bit/ cleaner, but it has one big problem: the content isn't run
through str:encode-uri().
Any ideas? How would you write my initial code snippet in the cleanest, most
beautiful way while staying functionally equivalent?
======================================================================
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|