[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
Re:  Some entities output as entities and others as cha
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','&#146;'),'b','&#147;'),'b','&#148;'),'B.','&#174;'),'b"','&#153;')
       ,'b','&#151;'),'B7','&#183;'),'n :','&#59450;'),'b','&#150;'),'C)','&#233;')
       ,'B>','&#190;'),'C>','&#254;'),'o','&#111;'),'b"','&#149;'),'C"','&#226;')
       ,'C<','&#252;'),'C','&#220;'),'b,','&#128;'),'b ','&#134;'),'x','&#120;')
       ,'B(','&#168;'),'B'','&#167;'),'b','&#8211;'),'C#','&#227;'),'b','&#8212;')
       ,'D','&#259;'),'B)','&#169;'),'C-','&#237;'),'C(','&#232;'),'C'','&#231;')
       ,'C!','&#225;'),'b','&#145;'),'C=','&#253;'),'b!','&#135;'),'B#','&#163;')
       ,'b','&#8542;'),'B<','&#188;'),'B=','&#189;'),'B>','&#190;'),'B4','&#180;')
       ,'C:','&#250;'),'C1','&#241;'),'C0','&#240;'),'C8','&#248;'),'C3','&#243;')
       ,'C*','&#234;'),'C ','&#224;')"/>

If I copy the above into some text to use as test data one sees good
output as a pair of entities like&#146;','&#146; 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,'&#146;','&#146;'),'&#147;','&#147;'),'&#148;','&#148;'),'B.','B.')
     ,'&#153;','&#153;'),'&#151;','&#151;'),'B7','B7'),'n :','n :'),'&#150;','&#150;')
     ,'C)','C)'),'B>','B>'),'C>','C>'),'o','o'),'&#149;','&#149;'),'C"','C"'),'C<','C<'),'C','C')
     ,'&#128;','&#128;'),'&#134;','&#134;'),'x','x'),'B(','B('),'B'','B''),'&#151;','&#150;')
     ,'C#','C#'),'b','&#151;'),'D','D'),'B)','B)'),'C-','C-'),'C(','C('),'C'','C''),'C!','C!')
     ,'&#145;','&#145;'),'C=','C='),'&#135;','&#135;'),'&#146;','&#146;'),'B#','B#')
     ,'&#147;','&#147;'),'&#148;','&#148;'),'&#149;','&#149;'),'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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.