i have a web-page that returns XML
with an xsl
stylesheet transform, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='/css/homepage.xsl'?>
<MyData>
...
</MyData>
It properly displays the transformed XSL as HTML. But when i try to view the XML source, Internet Explorer gives me the error:
The XML source file is unavailable for viewing
Some people claim that this behaviour is by design.
But i can give you a site where the desired behaviour works perfectly (Blizzards WoW Armory) (i.e. you can view the xml source):
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/_layout/pageIndex.xsl"?>
<page globalSearch="1" lang="es_mx" requestUrl="/index.xml" type="front">
<pageIndex>
<related-info/>
</pageIndex>
</page>
So the argument that "this behaviour is by design" is disproven by direct observation.
What is wrong with my XML, that the source XML cannot be shown?
Leading you down the wrong path
Here is some supplemental information.
Http response headers from Blizzard's (working) site:
GET http://www.wowarmory.com/ HTTP/1.1
HTTP/1.1 200 OK
...
Content-Type: text/xml;charset=UTF-8
Content-Length: 233
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/_layout/pageIndex.xsl"?><page globalSearch="1" lang="es_mx" requestUrl="/index.xml" type="front">
<pageIndex>
<related-info/>
</pageIndex>
</page>
And here are the response headers from my (borken) xml:
GET http://www.example.com/default.ashx HTTP/1.1
HTTP/1.1 200 OK
...
Content-Type: text/xml; charset=utf-8
...
Content-Length: 131974
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='/css/homepage.xsl'?>
<MyData>
...
</MyData>