Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XSLT and DOCTYPE not working in IE

Posted on 2006-06-23
3
Medium Priority
?
1,089 Views
Last Modified: 2008-01-16
I have created a simple XSL->XML solution (see below). The problem is I cannot get IE to see the DOCTYPE setting. I want the HTML 4.01 Transitional doctype to come through or else IE ignores my positioning I have setup in the css file. It works fine in FireFox but not in IE. In IE the page is displayed but the positioning information is ignored. (This is when I access the file http://server/test.xml)

I also wrote an ASP script to return the page as XHTML - this has the same result as above - but I did notice the file has the header shown below when it comes down (this is the file generated by the asp script - see below for code). If I remove the first line of the returned XHTML file (<?xml version ... ?>) save the file to the webserver and load it all is well.

Any ideas - I did spend some time googling this - but did not really find much - any ideas

[Returned header from test.asp]

<?xml version="1.0" encoding="UTF-16"?>   <-- This appears to be the offending item
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

[TEST.XML]
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<stuff>
<config>
 ...
</config>
[END TEST.XML]
The XSL file

[TEST.XSL]
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=
  "http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
  doctype-system="http://www.w3.org/TR/html4/loose.dtd"
  doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" indent="yes" />
<xsl:template match="/">
<html>
<head>
  ...
  <link type="text/css" rel="stylesheet" href="css/layout.css" />
</head>
<body>
 ....
</body>
[END TEST.XSL]

[TEST.ASP]
<%
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("test.xml"))

'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("test.xsl"))

'Transform file
Response.Write(xml.transformNode(xsl))
%>
[END TEST.ASP]
0
Comment
Question by:Julian Hansen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
mshogren earned 2000 total points
ID: 16971310
Hi,

I think you need to change the output method from XML to HTML.  You have
<xsl:output method="xml"
which should be
<xsl:output method="html"
0
 
LVL 59

Author Comment

by:Julian Hansen
ID: 16974462
Thanks Michael

I tried that but did not seem to make a difference - only tried once though - will keep trying different options and report back.
0
 
LVL 59

Author Comment

by:Julian Hansen
ID: 16974527
Ok - that did the trick

All I had to do was change

<xsl:output method="xml" ...

To

<xsl:output method="html" ...

And remove the

<?xml version="1.0" encoding="ISO-8859-1"?>

From the top of the XML file and it all works very nicely ... guess next time I should read the technical specs.

Thanks for the response
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question