I'm trying to use XSLT text output to generate a file (in a file format that I'm not in control of), and while it is mostly text, it includes low-order non-printable characters as flags, including characters that are not valid within an XLST file (according to the XSLT specification).
I'd like for something like the below to work, but instead it isn't a valid XSLT file since it it contains characters that are not allowed in XSLT files:
<?xml version="1.0" encoding="US-ASCII" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="US-ASCII"/>
<xsl:template match="/"></xsl:template>
</xsl:stylesheet>
I get the following error:
[Fatal Error] :4:35: Character reference "" is an invalid XML character.
ERROR: 'Character reference "" is an invalid XML character.'
FATAL ERROR: 'Could not compile stylesheet'
I've tried with an actual character 1 too, with or without a CDATA section, xsl:text elements, xslt-2 character maps, a couple of different encodings, but I can't figure out how to get a ascii character with binary code = 1.
I've had to resort to post-processing my output, which isn't ideal.
Is there any way to generate a single low-order non-printable character output from XSLT?
Environment: Java 6, built in XSL Transformer.