xsl-list
[Top] [All Lists]

Re: links don't work when IE transforms XSL document

2004-10-01 04:17:03
Passin, Tom wrote:

Here are my results using your stylesheet -

1) Running the transform with msxml3 produced identical results for the
source document consisting of "<root/>", and the source document
consisting of the stylesheet.  I compared them using examdiff, and they
were exactly the same, as one would expect.
So far, the same results here.

2) In both IE6sp1 and Firefox 0.9.2 in Win2000 sp4, the internal links
were visible and worked as expected.
Yes, when I open the generated output file in the browser, the links work. It's only when I open the stylesheet directly in the browser (via <?xml-stylesheet PI) that they don't work... Have you tried this? Because if the links work for you, I can't understand why they don't work here: I also have IE6sp1
(on Win98, but can that make any difference?)

BUT note that you won't get that result just loading the output into IE
from the file system, at least not if it has a file extension of ".xml".
IE knows nothing about xhtml, and needs to see a .html extension, in
which case IE treats the file as an ordinary html file.  Otherwise it
displays it as xml, which would certainly cause someone to say that they
did not see any links.
Using xml:output method="html" doesn't seem to make any difference (see below)

I suspect your problem is either the file extension or the MIME type the
file is served with.  IE will try to figure out the file type based on
the MIME, extension, and also the file contents.  I don't know how you
are serving it, but perhaps the combination of the declared type plus
something else causes the difference.  Do you use on embedded stylesheet
PI to specify the stylesheet, or do you transform it separately before
serving it to the browser?  You should look into those factors, and also
explain clearly exactly what was observed instead of the expected
results.
I want to use the embedded stylesheet PI. Here's the original stylesheet:
http://users.telenet.be/cking/webstuff/xdoc/xdoc.xsl

The stylesheet is meant to transform any xsl file, including itself (via the xml-stylesheet PI).
Now what happens is:

1. in Mozilla (Firefox 0.9.3 and 1.0PR) the links work fine
2. in IE6, the links don't work ("Cannot find server or DNS Error")
3. if I use the the "MSXML-XSL Output IE" tool [1] to display the html output, then copy and paste it in a file "result.html" and open that in the browser, the page looks exactly the same, but now the links do work.

So I tried to cut things down to the smallest stylesheet that still demonstrates the problem, I already posted that, but here's a slightly shorter version that uses xsl:output method="html":

--- anchors.xsl ---
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="anchors.xsl"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:output method="html" indent="yes"/>
   <xsl:template match="/">
       <html>
           <head>
               <title>anchors</title>
               <style type="text/css">div {padding-bottom: 500px;}</style>
           </head>
           <body>
               <div>
                   <p>contents</p>
                   <ul>
                       <li><a href="#s1">Section 1</a></li>
                       <li><a href="#s2">Section 2</a></li>
                       <li><a href="#s3">Section 3</a></li>
                   </ul>
               </div>
               <div><a id="s1"></a><h1>Section 1</h1></div>
               <div><a id="s2"></a><h1>Section 2</h1></div>
               <div><a id="s3"></a><h1>Section 3</h1></div>
           </body>
       </html>
   </xsl:template>
</xsl:stylesheet>

The links are broken (1) only in IE, (2) only when the <?xml-stylesheet PI is used (ie. client-side)
*and* (3) only if an xsl file is used as input: if I send this file to IE:

--- dummy.xml ---
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="anchors.xsl"?>
<dummy/>

the links work fine... but as soon as I just rename "dummy.xml" to "dummy.xsl" the links are broken again!

Sorry for the long post, but this one is breaking my head, and I wanted to describe things as clearly as possible.
Any feedback is greatly appreciated!

Thanks,
Anton


[1] http://www.microsoft.com/downloads/details.aspx?FamilyId=D23C1D2C-1571-4D61-BDA8-ADF9F6849DF9&displaylang=en