Problems with character encoding & XML transform

Hi all,

I try to create a podcast UI with openhab and XSLT transforms; unfortunately I can not get the special characters (umlaute like öäü) to display correctly in the web UI.

I did try to use ISO-8859-1 in the xslt as well as utf-8; both with the same result:

My item definition:
> String DescriptionPodcast0 "Beschreibung: [%s]" <none> (gPodcast0) { http="<[http://www.deutschlandfunk.de/podcast-forschung-aktuell.677.de.podcast.xml:600000:XSLT(podcastDescription.xsl)]"}

And the transform:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml" encoding="ISO-8859-1" omit-xml-declaration="yes" />
	<xsl:template match="/">
        <xsl:value-of select="rss/channel/description" />
	</xsl:template>
</xsl:stylesheet>

I’m using OH 1.8.2 on M$-Windows 10.
Any ideas how to solve this?

thanks and kind regards,
Patrik

… also did try to use character maps; but it looks like version2.0 is not supported for transforms … so this did not work either.

> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
>     <xsl:output method="xhtml" use-character-maps="html"></xsl:output>
>     <xsl:character-map name="html">
>         <xsl:output-character character="ä" string="&amp;#228;"></xsl:output-character>
>         <xsl:output-character character="ö" string="&amp;#246;"></xsl:output-character>
>         <xsl:output-character character="ü" string="&amp;#252;"></xsl:output-character>
>         <xsl:output-character character="Ä" string="&amp;#196;"></xsl:output-character>
>         <xsl:output-character character="Ö" string="&amp;#214;"></xsl:output-character>

Try using the java/json character maps (example for ö: Unicode Character 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6)):
Continuing the discussion from Display Umlaute using on web page:

Hello sihui,

thank you very much for your feedback. Unfortunately openHAB 1.8.2 nor openHAB 2.0 beta seems to support character maps in xml transforms - thus this approach will not work :-(.

I’ll search if there’s another way to replace characters using xml transform version 1.0.

with kind regards,
Patrik

… did try to achieve the same only using 1.0 xslt stuff:

<?xml version="1.0" encoding="utf-8"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" method="text" encoding="utf-8" omit-xml-declaration="yes" />

    <xsl:template match="/">
        <xsl:variable name="description" select="rss/channel/description"/>
        <xsl:value-of select="translate($description, 'äöü','&#228;&#246;&#252;')"/>
    </xsl:template>

</xsl:stylesheet>

Unfortunately did not work in OH 1.8.2; nor in 2.0 Beta (error below from OH 1.8.2):

ERROR: 'Klasse "xpath-functions" kann nicht gefunden werden.' FATAL ERROR: 'Das erste Argument für die nicht-"static"-Java-Funktion "translate" ist keine gültige Objektreferenz.'

If you are using Notepad++ for editing, just choose Menu -> Encoding -> Encode in UTF-8

Hi Timon,
thank you for your feedback - I’ve checked the encoding; UTF-8 w/o BOM; unfortunately this is not the problem.

with kind regards,
Patrik