Hi all!

Back in 2013, a question was asked about how to preserve entities (e.g.,
unicode and emojis) when transforming:

"My XSLT transformations have been successful for months until I ran across
an XML file with Unicode characters (emoji characters). I need to preserve
the Unicode but XSLT is converting it to HTML Entities. I thought that
setting the encoding to UTF-8 would solve my problem but I'm still having
issues."

The answer was to look at the 'xalan:entities' serializer:

http://xml.apache.org/xalan-j/usagepatterns.html#outputprops

I've switched from Xalan to Saxon to handle the conversion flawlessly,
using a single line of code:

      System.setProperty(
        "javax.xml.transform.TransformerFactory",
        "net.sf.saxon.TransformerFactoryImpl" );

The downside is adding 6MB to encode emojis, which Xalan is already doing,
just not quite as needed (�� is generated instead of
👍, for example).

Is there an example showing how to use the xalan:entities serializer to
preserve entities?

Thank you!

Reply via email to