[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] formatting problem


Subject: RE: [xsl] <xsl:attribute name="href"> formatting problem
From: "Josh Canfield" <Josh.Canfield@xxxxxxxxxxxx>
Date: Thu, 6 May 2004 12:02:15 -0700

Even better...
    <a href="#" onclick="alert('{$var1}')">Link</a>

-----Original Message-----
From: Josh Canfield 
Sent: Thursday, May 06, 2004 11:54 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] <xsl:attribute name="href"> formatting problem


I would guess that the html serializer is smart enough to know that you can't have an umlaut in a URL, but not smart enough to detect that you are in a javascript function (just a guess).

I would suggest using the onclick attribute, and setting the href to #

Something like:

<a href="#" onclick="{concat('myFunc(&quot;',$var1, '&quot;)')}">Link</a>

or if you prefer

<xsl:element name="a">
	<xsl:attribute name="href">#</xsl:attribute>
	<xsl:attribute name="onclick">myFunc("<xsl:value-of select="$var1"/>"</xsl:attribute>Link</xsl:element>

which both generate:

<a href="#" onclick="myFunc(&#34;Fig.&nbsp;2&nbsp;Struktur ausw&auml;hlen&#34;)">Link</a>

Josh
-----Original Message-----
From: Bianca Poignee [mailto:bianca_p@xxxxxx]
Sent: Thursday, May 06, 2004 11:26 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] <xsl:attribute name="href"> formatting problem


I have a weird formatting problem with my XSL script output... :-(

I am using MSXML 4.0 and >IE5.5.

My script should generate an anchor with a call to a javascript function
that needs a string parameter. 

<xsl:element name="a"><xsl:attribute
name="href">javascript:myFunc('<xsl:value-of
select="$var1"/>')</xsl:attribute>Link</xsl:element>

The current value of var1 contains the german umlaut for "a" and some &#160;
characters ("Fig.&#160;2&#160;Struktur ausw#a#hlen" where the #a# is the
german umlaut)

If I do the transformation like written above, my result is as follows:
Fig.%C2%A01%C2%A0Struktur ausw%C3%A4hlen

BUT! If I use a different attribute name (like "test" instead of "href"),
then my string doesn't get formattet like this, but the result is:
Fig. 1   Struktur ausw#a#hlen

How can I reach a formatting that doesn't come with "%C2%A0" and all that
stuff when using "href"? My javascript would need to decode all of them
manually otherwise.. ;-)

Thanks for any help,
Bianca from Germany

-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info


Current Thread
Keywords
xsl