RE: [xsl] encoding shift_jis into an attribute

Subject: RE: [xsl] encoding shift_jis into an attribute
From: "Josh Canfield" <Josh.Canfield@xxxxxxxxxxxx>
Date: Wed, 2 Jun 2004 14:08:40 -0700
What you are seeing is the url encoding of the characters because they appear in the href attribute, with an output method set to html.

More info:

or search for "url encoding unicode" in your favorite search engine.


-----Original Message-----
From: Matthew Simoneau [mailto:Matthew.Simoneau@xxxxxxxxxxxxx]
Sent: Wednesday, June 02, 2004 1:38 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] encoding shift_jis into an attribute

Hi everyone,

I'm trying to figure out how to HTML encode shift_jis text and put it
into an attribute.

I start with this XML-file with characters encoded in shift_jis:

<?xml version="1.0" encoding="shift_jis"?>

?? are two Japanese characters in the file, but I wanted to send this
out as ASCII for maximum legibility.

When I apply this simple stylesheet

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE xsl:stylesheet>
  <xsl:output method="html"/>

<xsl:template match="test">
      <xsl:value-of select="label"/>


it creates output that looks like this:


Notice how the shift_jis characters have been HTML escaped (or encoded?)
and display fine in the browser.  So far so good.  But now I want to put
these escaped characters into an attribute.  Here is the HTML I'd really
like to make:

   <body><a href="matlab:disp('&#25968;&#23398;')">foo</a></body>

Notice that the same two encoded Japanese characters are now within an
attribute and surrounded by some other text.  I've tried every trick I
know and searched all over the Internet, but haven't been able to figure
this one out.  Whenever I try to put it into an attribute (using
<xsl:attribute> or something), I get "%E6%95%B0%E5%AD%A6" (which I don't
even understand), not "&#25968;&#23398;" (which is what I want).

Can someone please point me in the right direction?  Thanks for your

XSL-List info and archive:
To unsubscribe, go to:
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>

Current Thread