[xsl] Twig::, Xalan, and Character Escaping

Subject: [xsl] Twig::, Xalan, and Character Escaping
From: "Monte Hayward" <monte@xxxxxxxxxxxxxxx> (by way of Mulberry Technologies List Owner)
Date: Tue, 20 Mar 2001 12:58:03 -0500
I'm writing algorithmically identical code for Perl and Java, using Twig:: and Xalan 1.2.2, respectively. Am running into yet
another interesting XSL / XML puzzle.

Because I am trying to shove normal URLs and javascript calls into a single Element Value, I want to store and retrieve Strings of
two types:
1.  javascript:myFunc(&apos;http://thesite.com/file.ram&amp;cp=1999+Owner&amp;spk=383608&amp;rmp&apos;);
2. http://site.com/player.asp?id=1032"; TARGET="player
That's right - I want those oddly placed quote marks in example 2. And I don't want them encoded as latin-iso char equivalents or
URL encoding.

The XML that is delivered:
1. <HRF>javascript:myFunc(&apos;http://site.com/file.ram&amp;cp=1999+Owner&amp;spk=383608&amp;rmp&apos;);</HRF>
2. <HRF>http://site.com/influences.mov?id=1012&amp;foo=bar&quot; TARGET=&quot;playwin</HRF>

What TWIG:: Outputs:
1. myFunct(&apos;http://site.com/file.ram&amp;cp=&amp;spk=&amp;rmp&apos;);
   Wrong![Netscape does not decode the &apos;. Javascript error.]
2. http://site.com/player.asp?id=1032&amp;foo=bar&quot; TARGET=&quot;playwin
   Wrong! &quot; should have converted to "

What Xalan spews:
1. javascript:p('http://www.virtuetv.com/foo.asx&cp=&spk=3836082&wmp');
   Correct!
2. http://site.com/player.asp?id=1032&foo=bar%22%20TARGET=%22p
   Wrong! Xalan is somehow URL-encoding the String!
   Even though we know that XSL does not have a URLencode() method!


If I give up the hope of sending URLs of type 2 to a new browser window (target=playwin), I solve one problem, the quote mess. Lose
one feature, kill one bug.

With type 1, TWIG always gives me a wrong result, it seems. The &apos; does not get decoded by Netscape or IE.

Anyone have ideas regarding character encodings across different parsers and XSL Transform Engines?

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


Current Thread