RE: [xsl] encoding shift_jis into an attribute

If you move your AVT you don't need the extra variables, or code:
<a href="matlab:disp('{label}');">foo</a>
is equivalent to
<a href="{concat('matlab:disp(', $singleQuote, label, $singleQuote,')')}">foo</a>
Josh
-----Original Message-----
From: M. David Peterson [mailto:m.david@xxxxxxxxxx]
Sent: Wednesday, June 02, 2004 2:13 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] encoding shift_jis into an attribute
Hey Matthew,
What you are seeing is escaped URL encoding... You are seeing it because
when you set the output to html and the processor comes across an href
attribute it decides that to properly output the reference link it needs to
URL encode it. Makes sense given the fact that the processor is being told
to output HTML.
If you change the output to XML you get halfway through your problem. And
by using a simple variable that encloses a ' inside an xsl:test container
you get even closer. This should help you get a little closer to where you
want to go...
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot;>
<xsl:output method="xml" encoding="shift_jis"/>
<xsl:template match="test">
<xsl:variable name="singleQuote"><xsl:text>'</xsl:text></xsl:variable>
<html>
<body>
<a href="{concat('matlab:disp(', $singleQuote, label, $singleQuote,
')')}">foo</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
will process this:
<?xml version="1.0" encoding="shift_jis"?>
<test>
<label>&#25968;&#23398;</label>
</test>
and output this:
<?xml version="1.0" encoding="shift_jis"?>
<html>
<body>
<a href="matlab:disp('&#25968;&#23398;')">foo</a>
</body>
</html>
Let me know if you need any further help in where to go next to ensure you
get the proper output you are looking for.
Best of luck!
<M:D/>
----- Original Message -----
From: "Matthew Simoneau" <Matthew.Simoneau@xxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, June 02, 2004 2:37 PM
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"?>
<test>
<label>??</label>
</test>
?? 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:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot;>
<xsl:output method="html"/>
<xsl:template match="test">
<html>
<body>
<xsl:value-of select="label"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
it creates output that looks like this:
<html>
<body>&#25968;&#23398;</body>
</html>
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:
<html>
<body><a href="matlab:disp('&#25968;&#23398;')">foo</a></body>
</html>
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
help!
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--