469,361 Members | 2,310 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,361 developers. It's quick & easy.

How to display special characters in XSL

Hi,

I have a XML file which looks like this.

<article_content id="364098" status="A">
<title>Weekly Sector Review</title>
<date>20041008</date>
<time>09:11:00</time>
<body>BP’s third quarter figures were well received with
investors cheering the prospect of enormous profits this year and
possibly more to come with oil prices remaining stubbornly high.
<introduction>Weekly review of the biggest sector
movers</introduction>
<category_id>0100</category_id>
</article_content>

How can make so that the XSL will display the character ’ as '
in the HTML page?

Thanks a lot

GA
Jul 20 '05 #1
5 12799
On 9 Oct 2004 05:14:07 -0700, ga************@hotmail.com (Gaizka)
wrote:
How can make so that the XSL will display the character ’ as '
in the HTML page?


XSL doesn't "display" things, it just makes another output document,
typically as either HTML or XML. It's default behaviour will be to
generate ’ in the output, exactly as for the input. For HTML,
this is perfectly adequate - ’ is valid,

In some obscure cases (I was bitten by this with Vodafone's
PaertnerML) ’ isn't acceptable. I had to whack it with some
JavaScript and a regex.
--
Smert' spamionam
Jul 20 '05 #2
Andy Dingley <di*****@codesmiths.com> wrote in message news:<g1********************************@4ax.com>. ..
On 9 Oct 2004 05:14:07 -0700, ga************@hotmail.com (Gaizka)
wrote:
How can make so that the XSL will display the character ’ as '
in the HTML page?
XSL doesn't "display" things, it just makes another output document,
typically as either HTML or XML. It's default behaviour will be to
generate ’ in the output, exactly as for the input. For HTML,
this is perfectly adequate - ’ is valid,


ok the character in the XML file is &#8217 and I need transform it to
' in the HTML file

In some obscure cases (I was bitten by this with Vodafone's
PaertnerML) ’ isn't acceptable. I had to whack it with some
JavaScript and a regex.

Any other option than replacing it? :(

thanks

GA
Jul 20 '05 #3
On 11 Oct 2004 04:10:40 -0700, ga************@hotmail.com (Gaizka)
wrote:
ok the character in the XML file is &#8217 and I need transform it to
' in the HTML file


Why ? Is it really not working ? - this entity ought to be perfectly
valid and workable in all cases, as a substitute for the character.

You can't really control this in XML. It's part of the fundamentals of
XML that the two representations are interchangeable, and so you don't
have control over it. If you wanted to, you would have to either
re-write or replace the XML serialiser that generates your output
document.

If you change the XSL output mode to text (or possibly HTML) then the
serialiser _may_ stop generating the entity, although this is platform
dependent.
You might find that you need to convert the "curly quote" to a
"straight quote". This is rare, but as mentioned, it does sometimes
arise.

If you want to substitute it, the XSL string function "translate()"
should be able to help. Or else you can use a piece of JavaScript and
a regex. Place either in a named template rule and pass them the
text() content of the affected elements.
--
Smert' spamionam
Jul 20 '05 #4
ok the character in the XML file is &#8217 and I need transform it to
' in the HTML file


You mean you need a real ascii ' in the file or just that you want it to
display as that?
As others have said, & #8217; should just work. Apart form anything
else, if you are generating HTML I would expect most XSLT engines to
output it as & rsquo; as they usually use html entities where possible.

If you need to generate an ascii ' then you can use translate as in
<xsl:value-of select="translate(.,'& #8217;',&quot;'&quot;)"/>

(without the space after the &) to replace any right quote characters in
the current element content.

David
Jul 20 '05 #5
Hi again and thanks for helpng this xml/xsl dummy :)

The XML feed contains &#8217 characters

i found out that, after the trasformation, n my tomcat development I see ' ... :)
In the production server I still see &#8217, and also ? instead of ... :(

is it Tomcat default encoding xml the difference?

many thanks

GA

David Carlisle <da****@nag.co.uk> wrote in message news:<yg*************@penguin.nag.co.uk>...
ok the character in the XML file is &#8217 and I need transform it to
' in the HTML file


You mean you need a real ascii ' in the file or just that you want it to
display as that?
As others have said, & #8217; should just work. Apart form anything
else, if you are generating HTML I would expect most XSLT engines to
output it as & rsquo; as they usually use html entities where possible.

If you need to generate an ascii ' then you can use translate as in
<xsl:value-of select="translate(.,'& #8217;',&quot;'&quot;)"/>

(without the space after the &) to replace any right quote characters in
the current element content.

David

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by mikel | last post: by
7 posts views Thread by Roy W. Andersen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.