472,353 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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 12907
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mikel | last post by:
Hello, I have several characters in my html code like / W and so on.... The problem is, tehy are converted in HTML in their approbiate...
7
by: Roy W. Andersen | last post by:
I've been searching google about this for days but can't find anything, so I'm hoping someone here can help me out. I'm trying to create...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API...
17
by: Carl Mercier | last post by:
Hi, Is it possible to use special characters like \n or \t in a VB.NET string, just like in C#? My guess is NO, but maybe there's something I...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve....
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am...
5
by: iegeek | last post by:
Hi all, I know this is a well-worn topic, but in viewing multiple posts and articles, I still can't find a satisfactory answer. I have embedded...
1
by: sonald | last post by:
Dear All, I am working on a module that validates the provided CSV data in a text format, which must be in a predefined format. We check for the :...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and...
0
by: AAaron123 | last post by:
Been playing with asp:changepassword and have it looking OK except that I can't elininate or change the title at the top that says "Change Your...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.