This was working for many weeks but since a couple of days I am observing that the server seems to provide the information in json format which cannot be processed with my xsl transformation file.
Therefore I would like to specify the content-type when requesting the server.
Does anyone know the syntax to extend the item defintion?
I guess I have to add some extentions in {} in the config file but I am lost on the syntax.
http:Bayern3.url=http://www.br.de/wettervorhersage/services/rest/weatherdata/81825{Accept=application/xml&Content-Type=application/xml}
could be something in the direction …
or maybe in items.
Number bayern3_wetter_temperature_today_min “Min Temperature heute [%.1f °C]” // {http="<[Bayern3{Accept=application/xml&Content-Type=application/xml}:600000:XSLT(bayern3_temp_min_today.xsl)]"}
yes, in a browser it does but openhab does not. This is what I am receiving as an error.
2016-05-30 06:23:45.195 [ERROR] [.i.s.XsltTransformationService] - transformation throws exception
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Content ist nicht zulässig in Prolog.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source) ~[na:1.8.0_91]
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source) ~[na:1.8.0_91]
at org.openhab.core.transform.internal.service.XsltTransformationService.transform(XsltTransformationService.java:83) ~[na:na]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:182) [bundlefile:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.0.jar:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.0.jar:na]
Caused by: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Content ist nicht zulässig in Prolog.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(Unknown Source) ~[na:1.8.0_91]
… 6 common frames omitted
Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Content ist nicht zulässig in Prolog.
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source) ~[na:1.8.0_91]
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source) ~[na:1.8.0_91]
… 7 common frames omitted
2016-05-30 06:23:45.244 [ERROR] [.o.b.http.internal.HttpBinding] - transformation throws exception [transformation=XSLT(bayern3_date_today.xsl), response={“day”:[{“date”:1464559200000,“temperatureMin”:{“value”:“13”,“Unit”:“°C”},“temperatureMax”:{“value”:“20”,“Unit”:“°C”},“windSpeedMax”:{“value”:“20”,“direction”:null,“directionshort”:null,“Unit”:“km/h”},“windSpeedGuestMax”:{“value”:“37”,“direction”:null,“directionshort”:null,“Unit”:“km/h”}},{“date”:1464645600000,“temperatureMin”:{“value”:“12”,“Unit”:“°C”},“temperatureMax”:{“value”:“20”,“Unit”:“°C”},“windSpeedMax”:{“value”:“9”,“direction”:null,“directionshort”:null,“Unit”:“km/h”},“windSpeedGuestMax”:{“value”:“22”,“direction”:null,“directionshort”:null,“Unit”:“km/h”}}]}]
org.openhab.core.transform.TransformationException: transformation throws exception
at org.openhab.core.transform.internal.service.XsltTransformationService.transform(XsltTransformationService.java:86) ~[na:na]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:182) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.0.jar:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.0.jar:na]
Caused by: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Content ist nicht zulässig in Prolog.
2016-05-31 05:35:17.548 [DEBUG] [.o.b.http.internal.HttpBinding] - item 'HttpTest' is about to be refreshed now
2016-05-31 05:35:18.374 [DEBUG] [.o.b.http.internal.HttpBinding] - transformed response is '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><weatherdata><day><date>2016-05-31T00:00:00+02:00</date><temperatureMin><value>11</value><Unit>°C</Unit></temperatureMin><temperatureMax><value>19</value><Unit>°C</Unit></temperatureMax><windSpeedMax><value>11</value><Unit>km/h</Unit></windSpeedMax><windSpeedGuestMax><value>22</value><Unit>km/h</Unit></windSpeedGuestMax></day><day><date>2016-06-01T00:00:00+02:00</date><temperatureMin><value>13</value><Unit>°C</Unit></temperatureMin><temperatureMax><value>18</value><Unit>°C</Unit></temperatureMax><windSpeedMax><value>19</value><Unit>km/h</Unit></windSpeedMax><windSpeedGuestMax><value>37</value><Unit>km/h</Unit></windSpeedGuestMax></day></weatherdata>'
2016-05-31 05:35:18.391 [INFO ] [runtime.busevents ] - HttpTest state updated to <?xml version="1.0" encoding="UTF-8" standalone="yes"?><weatherdata><day><date>2016-05-31T00:00:00+02:00</date><temperatureMin><value>11</value><Unit>°C</Unit></temperatureMin><temperatureMax><value>19</value><Unit>°C</Unit></temperatureMax><windSpeedMax><value>11</value><Unit>km/h</Unit></windSpeedMax><windSpeedGuestMax><value>22</value><Unit>km/h</Unit></windSpeedGuestMax></day><day><date>2016-06-01T00:00:00+02:00</date><temperatureMin><value>13</value><Unit>°C</Unit></temperatureMin><temperatureMax><value>18</value><Unit>°C</Unit></temperatureMax><windSpeedMax><value>19</value><Unit>km/h</Unit></windSpeedMax><windSpeedGuestMax><value>37</value><Unit>km/h</Unit></windSpeedGuestMax></day></weatherdata>
Thanks Steve for taking the time.
Really appreciate this!!
It seems that your solution having the url direct in the item defintion avoiding the cached approach did the trick.Still unclear for me, because the cached approach worked for some time.
I’ve taken another look at the source code for the http binding and I think that the problem with the caching was that the headers must be specified in http:Bayern3.url rather than in the item binding.