I’ve got an XSL template that outputs text as opposed to XML.
In this text, I need to include ASCII character 0x10 in certain position.
I understand this character is not allowed in an XML document, but I’m going to output text, so why am I not allowed to use it anyway?
I also understand it will not be possible to put this character literally into the template, neither within a CDATA section nor as . But why does on-the-fly generation not work either? I tried, for instance, to define a function that returns this char and used it as <xsl:value-of select="z:get_char(16)"/> but that produces an Invalid character exception either.
Is there a way?
The Microsoft .NET framework does not support XML 1.1, that is true, but it has its own (not portable) way to use control characters in XML 1.0 documents, namely you can have as a numeric character reference if you set CheckCharacters to false on your XmlReaderSettings/XmlWriterSettings.
Here is an example stylesheet and some .NET code tested with .NET 3.5 that does not throw an illegal character exception: