RE: [xsl] asp.net tags

Subject: RE: [xsl] asp.net tags
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Mon, 6 Sep 2004 10:18:57 +0100
> > and the xslt
> >   <xsl:template
> >    match="myns:Url">
> >     <xsl:if
> >      test="../@type='Image'">
> >       <div>
> >         <a
> >          href="PhotoPress/{.}"
> >          title="Copyright by {../myns:Copyright}">
> >           <cc1:dynamicimage
> >            runat="server"
> > XXX           imagefile="<%# GetThumbnail("PhotoPress/{.}") %>">
> >           </cc1:dynamicimage>
> >         </a>
> >       </div>
> >     </xsl:if>
> > ...
> >
> > of course the line marked with XXX is not parsing at all.
> But I do not
> > want to use &gt; as I need the actual < for the code to be executed.
>
> Some XSLT processors have extensions that will allow you to
> disable output escaping in attribute values, but if yours
> doesn't, then use DOE to output the cc1:dynamicimage element
> as a text node, not as an element node.

If you are using XSLT 2.0, you can use character maps:

<xsl:character-map name="escape-atts">
    <xsl:output-character character="&lt;" string="&lt;"/>
    <xsl:output-character character="&gt;" string="&gt;"/>
</xsl:character-map>

Remember to specify the map on xsl:output:

<xsl:output use-character-maps="escape-atts"/>

Also, you will have to nest your quotes correctly on the line:

imagefile="&lt;%# GetThumbnail("PhotoPress/{.}") %&gt;"

To:

imagefile='&lt;%# GetThumbnail("PhotoPress/{.}") %&gt;'

Or escape them to:

imagefile="&lt;%# GetThumbnail(&#34;PhotoPress/somefile.gif&#34;)
%&gt;">

And add the extra mapping:

<xsl:output-character character="&#34;" string="&#34;"/>

Cheers
andrew

Current Thread