[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Some entities output as entities and others as cha
Subject: Re: Some entities output as entities and others as chars not looking good in the html.. why?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 13 Dec 2011 22:05:40 +0000
|
On 13/12/2011 18:02, Alex Muir wrote:
Hi,
I've got some currently inefficient code that is to convert some
characters to entites for html output like so. Will move this into a
analyze string function with a lookup later, but the problem other
than speed is that some of the characters are not being replaced as
entities.
...replace(replace(replace(replace(replace(replace(replace(replace(
$arg,'b','’'),'b','“'),'b','”'),'B.','®'),'b"','™')
,'b','—'),'B7','·'),'n :',''),'b','–'),'C)','é')
,'B>','¾'),'C>','þ'),'o','o'),'b"','•'),'C"','â')
,'C<','ü'),'C','Ü'),'b,','€'),'b ','†'),'x','x')
,'B(','¨'),'B'','§'),'b','–'),'C#','ã'),'b','—')
,'D','ă'),'B)','©'),'C-','í'),'C(','è'),'C'','ç')
,'C!','á'),'b','‘'),'C=','ý'),'b!','‡'),'B#','£')
,'b','⅞'),'B<','¼'),'B=','½'),'B>','¾'),'B4','´')
,'C:','ú'),'C1','ñ'),'C0','ð'),'C8','ø'),'C3','ó')
,'C*','ê'),'C ','à')"/>
If I copy the above into some text to use as test data one sees good
output as a pair of entities like’','’ and undesired output
which looks bad in the html as 'n :','n :' a pair of characters with the
entity converted to a char.
select="$arg,'’','’'),'“','“'),'”','”'),'B.','B.')
,'™','™'),'—','—'),'B7','B7'),'n :','n :'),'–','–')
,'C)','C)'),'B>','B>'),'C>','C>'),'o','o'),'•','•'),'C"','C"'),'C<','C<'),'C','C')
,'€','€'),'†','†'),'x','x'),'B(','B('),'B'','B''),'—','–')
,'C#','C#'),'b','—'),'D','D'),'B)','B)'),'C-','C-'),'C(','C('),'C'','C''),'C!','C!')
,'‘','‘'),'C=','C='),'‡','‡'),'’','’'),'B#','B#')
,'“','“'),'”','”'),'•','•'),'b','b'),'B<','B<')
,'B=','B='),'B>','B>'),'B4','B4')"
So why is this happening?
Btw if anyone can come teach some software engineering courses next
term at the university of gambia it would be welcome. I've injured my
ankle and won't be able to lecture so there is a gap that needs
filling. It's fairly easy to work remotely here on contracts as long
as you bring about 3 laptop batteries with you.
Thanks
note that numeric character references are not entity references in XML
(and get expanded at different times to entity references in some
circumstances). Character references always refer to unicode code points
so for example & # 1 3 7 ; refers to the control character
SET TRANSMIT STATE
which probably is not the character you intended?
some Microsoft encodings use characters in that range but (if th
encoding has been correcty declared in the input file) such characters
will be converted to their Unicode code points before XSLT sees the
input data.
There question is really, what encoding is your input in, and what
encoding do you wish your output to be> If these encodings are declared
then probably you don;t need to do any character transformations at all.
(If you do, then using translate() or character maps is probably simpler
than using regexp for this.,
David
--
google plus: https:/profiles.google.com/d.p.carlisle
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|