xsl-list
[Top] [All Lists]

Re: [xsl] Preserving numeric character entity reference

2007-02-14 04:12:09
Kjetil Kjernsmo wrote:
I can't use the us-ascii output encoding, as is usually suggested in cases like these, because, the numeric character entity references are actually in the us-ascii range anyway (and we want UTF-8 for the rest).
Is this doable?

Are there any other obfuscation techniques that can be done easily in XSLT that you can suggest?


Hi Kjetil,

You didn't specify the version of XSLT you are using, but here are a couple of ways that work with XSLT 2:

1. Use xsl:character-map to create literal strings like   for space and A for A, without the XML serializer interfering with it. 2. Use strings like   if obfuscation is all you want, and make sure to translate them back (translating character entities never cascade, i.e., &32; stands for the string " " and not for the entity  , as such you need to do extra translation to go from   back to a space char) 3. Use CDATA sections. But this creates different strings, the same way as with (2). 4. Use string-to-codepoints() to get the codepoints (which map directly to the entities) of the string.

I think (2) and (3) will work well with XSLT 1 as well, but both require you to do extra work in your obfuscating tool. If you "just" want to have your text translated to character entities, without the serializer (correctly) making them into readable US-ASCII, option (1) is the easiest and most extensible to do.

Cheers,
-- Abel Braaksma

--~------------------------------------------------------------------
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>