I have some issues with several XML Files that (unfortunately, against the specs) have control characters embedded, such as ETX or SOH.
I can't manipulate the files as I don't have access to the server. My company uses IE11* to show these XML files via XSL-Stylesheets and they work fine there. However when tried to view the files in EDGE** (as we plan to move forward and use this instead) they would not show at all. Console says "Resource interpreted as Stylesheet but transferred with MIME type application/xml" This is caused by the aforementioned control characters.
For example, the following XML will be visible fine in IE11*, but not on Edge and not on FFX (which I used for simple test/comparison):
XSL:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="/">
<html>
<head> <title> <xsl:value-of select="root/@title"/> </title>
<meta http-equiv='X-UA-Compatible' content='IE=8'/> </head>
<body>
<xsl:value-of select="root/mydata/text()"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML:
<?xml version='1.0' encoding='iso-8859-1' standalone='yes'?>
<?xml-stylesheet type='text/xml' href='../../stylesheet/soh.xsl'?>
<root title="XSL SOH Test">
<mydata> Data with SOH </mydata>
</root>
The XML file is opened via web browser, calling "127.0.0.1:8080/data/soh.xml". It is hosted on a PHP developer system run via cmd "php.exe -S "
Is there any way to ignore these Just like the IE11* seems to ignore them? (or is there a setting in the EDGE/IE11 I have to adjust?)
What I tried:
- XSL Output method "html", "text" and "xml"
- XSL transform() on the elements containing SOH
- XSL encapsulated affected elements in try/catch blocks
- XSL disable-output-escaping="yes" on elements containing SOH
- XML stylesheet-type "text/xsl", "text/xml", "application/xml"
I know that these characters are not allowed for XML (version 1.0), however I am confused as to why the IE11* is correctly showing the data, while EDGE and FFX can't. (I guess, because IE was more relaxed when it came to these things..)
If there is no way to fix this, could you provide a way to at least show an error message, like shown in FFX, because EDGE is just showing a blank page. As the document is ignored completely (due to SOH) try/catch isn't working either... The error in Firefox displays at least a message containing valuable info as to where the parsing failed:
XML Parsing Error: not well-formed
Location: 127.0.0.1:8080/data/soh.xml
Line Number 4, Column 28:
<mydata> Data with SOH </mydata>
-----------------------^
Thank you in advance and kind regards :)
*IE11 in v11.3143.14393.0/UpdateV 11.0.140(KB4511872) is working, the newer IE v11.1198.18362.0/UpdateV 11.0.220(KB4586769) shows the same behaviour as Edge.
** Talking about the chromium based EDGE here. (Adjusted after comment of Martin Honnen, thanks)