Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Escape XPath expression from string [Thread Next] Re: Escape XPath expression from stringTo: NULL Date: 12/5/2007 4:02:00 PM
Axel Bender wrote:
> I would like to replace the following code fragment:
>
> <xsl:variable name="icon2" select="normalize-space(@icons)" />
> <xsl:element name="img">
> <xsl:attribute name="src"><xsl:value-of select="/index/icon[@id =
> $icon2]/@path" /></xsl:attribute>
> </xsl:element>
Why do you use the verbose xsl:element and xsl:attribute when you can
use literal result elements and attribute value templates e.g.
<img src="{/index/icon[@id = $icon2]/@path}"/>
> with a shorter one, i.e. with another piece of code that makes direct
> use of the @icons value, e.g. (*not working*):
>
> <xsl:element name="img">
> <xsl:attribute name="src"><xsl:value-of select="/index/icon[@id =
> <@icons_value>]/@path" /></xsl:attribute>
> </xsl:element>
Try
<img src="{/index/icon[@id = normalize-space(current()/@icons)]/@path}"/>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
