If you want to write the output XML in a specific encoding you need to specify this on the xsl:output
instruction
<xsl:output method="xml" encoding="ISO-8859-1" />
The big benefit of configuring the encoding this way rather than fixing it up later with iconv
is that it means the XML serializer knows what the target encoding will be, and if your stylesheet tries to output any characters that are not representable in the selected character encoding then they will be preserved as character references rather than disappearing at iconv
time, for example
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="ISO-8859-1" />
<xsl:template match="/">
<example>אבג</example>
</xsl:template>
</xsl:stylesheet>
run over any XML document will produce
<?xml version="1.0" encoding="ISO-8859-1"?>
<example>אבג</example>
the three character references representing א, ב and ג respectively (remember Hebrew reads from right to left).