xsl-list
[Top] [All Lists]

RE: Converting to ASCII equivalent

2005-08-23 14:13:16
IMHO no extension would be needed if the OP was willing to invest 
the time in preparing the ASCII table in xml format. 
 
A table is not really necessary either.  This could easily be expanded 
into what the OP wanted: 
 
<xsl:variable name="char-ranking">  
<![CDATA[  
ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz 
]]>  
</xsl:variable>  
 
<xsl:variable 
   name="char-ord" 
   select="63 + string-length(substring-before($char-ranking,substring($str1, 
1, 1)))"  
/> 
 
Note: if $char-ord == 63, then character not found.  If character not 
found, then just copy the char into your output string.  Make sure 
char-ranking contains all possible characters you might want to 
translate into ASCII values. 
 
But recursion is still necessary to process the whole string.  Using 
CDATA, you can represent the entire ASCII chart ... expanding the 
solution is left up to the poster  ;-) 
 
P.S. I'd love to say I invented the ranking technique, but I saw it in 
a 'strcmp' implementation once. 
 
-- 
Rodman

P.P.S. sorry if this is double posted ... having email problems.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>