开发者

Why does changing the file extension of an XML file break its XSL transformation?

I have created a XML to HTML solution using XSLT, but the server I am storing the files on sets the content-disposition to "attachment" in the HTTP response header for XML files. Consequently, the browser attempts to download 开发者_开发百科the XML files as attachments instead of running the XSL transformation and displaying the HTML result in the browser. Unfortunately, changing the content-disposition to "inline" is not an option for me.

Changing the XML file extension to HTML was the first workaround I considered, but it only appears to work properly in IE, and only online (not offline). I don't understand this.

Can anyone tell me why renaming the file extension breaks the XSL transformation, and is there anything I can do to either the XML or XSL content to allow me to use this workaround? Thank you.

The first few lines of my XML file:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="includes/portal.xsl"?>

The first few lines of my XSL file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>


It is surely due to the returned content types returned by the server based on the file extension. What server are you using? Usually there is a way to configure the content type in other ways for specific files, directories or extensions. As a quick and easy check, try using the about using the .XHTML extension instead of .HTML or .XML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜