Closed Bug 272310 Opened 20 years ago Closed 19 years ago

XML Parsing Error occurs when using XSLT file on linux

Categories

(Core :: XSLT, defect)

1.7 Branch
x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED EXPIRED

People

(Reporter: rjkeller, Assigned: peterv)

Details

On Firefox 1.0 (final release) for Debian Linux, loading a XSLT stylesheet
causes the XML file to throw a XML parsing error (saying that the stylesheet is
null) when loaded from a local file. If the XML file is located on a web server,
parsing errors are not seen.

Note: This bug cannot be reproduced on Windows (XP, Firefox 1.0). It's linux
only and was reproduced on multiple linux systems.

Steps to reproduce:
1) Unzip this Zip file:
https://bugzilla.mozilla.org/attachment.cgi?id=153718&action=view
2) Open up forieusers.xml in Firefox
3) See parsing error

Screenshots:
When loaded from local file:
http://ghaint.no-ip.org:8942/~k2/test/nvuhelp/HDBrender_http.png
When loaded from web server:
http://ghaint.no-ip.org:8942/~k2/test/nvuhelp/HDBrender_http.png

Expected results:
It should parse the file just like on a web server. Shouldn't produce different
results on Linux and Windows. Obviously some platform-specific XSLT code is used
when it shouldn't be.
Oops, wrong local file URL :). This is the right one ->
http://ghaint.no-ip.org:8942/~k2/test/nvuhelp/HDBError_file.png
is this firefox specific or does it happen with mozilla too?
(In reply to comment #2)
> is this firefox specific or does it happen with mozilla too?

Same behaviour is shown by Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Gecko/20041007 Debian/1.7.3-5
and Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041119 Firefox/1.0
(Debian package 1.0-3) and by Epiphany 1.4.5

And Konqueror(3.3.1) only shows the text in the file. The only formatting that
it does is due the few html tags present.
I got an "XML parsing error: An XSLT stylesheet does not have an XML mimetype"
on my Debian system. But I fixed this by changing the mime type for xsl from
text/x-xslt to text/xml in /usr/share/mime/packages/freedesktop.org.xml and
running $ dpkg-reconfigure shared-mime-info. Thanks to
http://www.se.eecs.uni-kassel.de/~thm/Linux/mozilla-xml-xsl.html for the tip.

forieusers.xml now displays fine.
(In reply to comment #4)
> I got an "XML parsing error: An XSLT stylesheet does not have an XML mimetype"
> on my Debian system. But I fixed this by changing the mime type for xsl from
> text/x-xslt to text/xml in /usr/share/mime/packages/freedesktop.org.xml and
> running $ dpkg-reconfigure shared-mime-info. Thanks to
> http://www.se.eecs.uni-kassel.de/~thm/Linux/mozilla-xml-xsl.html for the tip.
> 
> forieusers.xml now displays fine.

Steffen, thanks for the work around. 

It would be interesting to find if this is Debian only or other flavours suffer
from this too. Someone reported a bug for shared-mime-info for Debian
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=281894 But there has been no
answer by any maintainer. I hope it gets resolved soon. 
I know we had a discussion in some bug about treating mimetypes that were
recieved from the OS as a 'hint' rather then an absolute truth. And then use the
nsUnknownDecoder to guess mimetype based on file contents.

Boris: Is that still something that we want to do, or was it desided against? Or
was I simply making this conversation up :)
It's something I've thought of on and off.  I'm not sure which way would break
more often, so it hasn't been done yet.  ;)
Linux | NLD (KDE)
Firefox 1.0.2

Reproducible: Always
Steps to Reproduce:
1. Create an XML file:
-----------XML FILE-----------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<database>
	<schema name="SCHEMA1">
		<table>
			<name>PERSON</name>
			<description>This table contains info about each person</description>
			<column>
				<name>PersonID</name>
				<notnull />
				<datatype>int</datatype>
				<description>Identity field that autoincrements for each person record
added</description>
			</column>
			<column>
				<name>FirstName</name>
				<datatype>varchar(50)</datatype>
				<description>First Name of this person</description>
			</column>
			<column>
				<name>DOB</name>
				<datatype>DateTime</datatype>
				<description>Date of birth for this person</description>
			</column>
		</table>
	</schema>
</database>
------------------------------------------


2. Create an XSL file:
-----------XSL FILE-----------------------
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="/">
		<html>
			<head><title>My Test</title></head>
			<body>
				<h2>Database</h2>
				<xsl:apply-templates/>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="schema">
		<schema>
			<div style="border: solid 1px #BBBBBB;">
				<span style="font-weight: bold;"><xsl:apply-templates select="@name"/></span>
				<xsl:apply-templates/>
			</div>
		</schema>
	</xsl:template>

	<xsl:template match="table">
		<table>
			<div style="border: solid 1px green; padding: 5px;">
				<div style="font-weight: bold;">
					<span style="color: magenta;"><name><xsl:apply-templates
select="name"/></name></span> -
					<xsl:apply-templates select="description"/>
				</div>
				<table border="1">
					<xsl:apply-templates/>
				</table>
			</div>
		</table>
	</xsl:template>

	<xsl:template match="column">
		<column>
			<tr>
				<td><xsl:apply-templates select="name"/></td>
				<td><xsl:apply-templates select="datatype"/></td>
				<td><xsl:apply-templates select="description"/></td>
			</tr>
		</column>
	</xsl:template>

</xsl:stylesheet>
------------------------------------------


3. Open the XML file in Firefox - it does not display the table correctly.
Actual Results:  
Table portion not displayed correctly - rows placed next to each other instead
of in standard table format

Expected Results:  
Similar output to Internet Explorer or the way the following html is displayed:

<html>
<head><title>My Test</title></head>
<body>
	<h2>Database</h2>
	<div style="border: solid 1px #BBBBBB;">
	<span style="font-weight: bold;">SCHEMA1</span>
	<div style="border: solid 1px green; padding: 5px;">
		<div style="font-weight: bold;">
			<span style="color: magenta;">PEOPLE</span> - This table contains info about
each person
		</div>
		<table border="1">
			<tr>
				<td>PersonID</td>
				<td>int</td>
				<td>Identity field that autoincrements for each person record added</td>
			</tr>
			<tr>
				<td>FirstName</td>
				<td>varchar(50)</td>
				<td>First Name of this person</td>
			</tr>
			<tr>
				<td>DOB</td>
				<td>DateTime</td>
				<td>Date of birth for this person</td>
			</tr>
		</table>
	</div>
</div>
</body>
</html>

Results:
Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype:

This only happens when using the "file" protocol in the URL (i.e.
file:///home/user/test.xml). When I use "http" in the URL (i.e.
http://host/test.xml) it doesn't give me the error.
(In reply to comment #8)
<rude>
Thanks Matthew, for wasting everybody's time and screen estate with no information
at all. Oh, and drop construction non-html elements in your output, relying on 
a sanitizing parser to drop all the <schema> and <column> cruft from your result.
Learning HTML before XSLT is a much more rewarding procedure.
</rude>
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → EXPIRED
I vote for this bug to be reopened. This is blocking XSLT support in the Help
Viewer. Comments?
(In reply to comment #12)
> I vote for this bug to be reopened. This is blocking XSLT support in the Help
> Viewer. Comments?

It is not, you can easily just use .xml files as stylesheets.

We could decide to change the order of OS and extras in
http://lxr.mozilla.org/seamonkey/source/uriloader/exthandler/nsExternalHelperAppService.cpp#2642,
though. If modern OSs tend to be less spec-conformant than we want to, this may
be good.
You can't change the order, since the OS is the only thing that knows how to
create the MIME info object.  The only thing you can do is override the OS with
information from the extras, but that's generally a bad idea, imo.  The extras
are just that -- extras.  They're not guaranteed to be those types.

All that said, doesn't xslt set a type hint on the channel?
(In reply to comment #13)
> 
> It is not, you can easily just use .xml files as stylesheets.
> 
> We could decide to change the order of OS and extras in
>
http://lxr.mozilla.org/seamonkey/source/uriloader/exthandler/nsExternalHelperAppService.cpp#2642,
> though. If modern OSs tend to be less spec-conformant than we want to, this may
> be good.

What we wanted to do was have a TOC automatically generated using XSLT. This
isn't possible with CSS as far as I know.
Who said anything about CSS?  All Peter said is that if you put your XSLT in a
file named myNeatXSLT.xml it really ought to work on all but the most broken
operating systems.
We do call SetContentType before opening the channel.

http://lxr.mozilla.org/mozilla/source/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp#551

Reporter, please verify that this is still a problem on a trunk build.
(In reply to comment #16)
> Who said anything about CSS?  All Peter said is that if you put your XSLT in a
> file named myNeatXSLT.xml it really ought to work on all but the most broken
> operating systems.

Sorry, I misinterpreted. This bug doesn't seem to have a testcase. I'll see if I
can cook one up in the next couple of days.
You need to log in before you can comment on or make changes to this bug.