473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 12978
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 characters like @ is @ and F is F But I DONT want to...
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 zip-files without needing the zip-file extension in PHP,...
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 function gives an error as "Unable to open input file"....
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 don't know. If it's not possible, does anybody...
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. I am trying to take the contents of a textarea box...
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 trying to have the data in the barcode be displayed in...
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 html in an xml file (element data, not attributes)...
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 : 1. Number of fields provided in the text file,...
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 some special characters inside a character class....
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 Password". It's a repeat of my pages title. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.