local drive XSL stylesheet

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Posts: 1
Joined: March 12th, 2013, 8:49 am

Post Posted March 12th, 2013, 8:57 am

I'm trying to determine the proper way to reference a local XSL stylesheet.

In the XML I have
<?xml-stylesheet type="text/xsl" href="C:/localdir/Generic.xsl"?>

This works in IE regardless of where I put the XML (typically the XML will be opened from an e-mail in our case).
I want to support Firefox. I found that if I change it to be
<?xml-stylesheet type="text/xsl" href="Generic.xsl"?>
it will work, but only if the XML in opened from the same directory as it is located. I would like for it to reference the exact location, so it continues to work with IE, and hopefully with Firefox as well.




User avatar
Posts: 124078
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted March 12th, 2013, 10:19 am

Moving to Web Development.


User avatar
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium

Post Posted March 12th, 2013, 1:55 pm

it will work, but only if the XML in opened from the same directory as it is located.

Sounds like you should try relative paths. Here's some info: ... 40502a.htm

If you do indeed want absolute paths, you should probably use something like file://localhost/c/directory (dunno the specifics; you'll probably end up with that if you simply type c:\ in Fx), but if you use relative paths it doesn't matter if you copy or move the whole thing about.
Intelligent alien life does exist, otherwise they would have contacted us.


User avatar
Posts: 2660
Joined: June 9th, 2008, 10:53 am
Location: Near 37.501685 -80.147967

Post Posted March 14th, 2013, 10:46 pm

If it is working in IE it should be ok in Firefox too, but Id confirm your file name extension. Should it be .xls rather than xsl?
~ I'm only here to Pay it Forward. ~

"I often take a very long windy road to my destination. When I arrive I often wonder how I missed the shortcut".

Posts: 6
Joined: March 4th, 2013, 9:28 am

Post Posted March 21st, 2013, 9:54 am

One thing to keep in mind is that with more recent versions, if the stylesheet is not in the same directory as the XML file (or in a subdirectory) it won't work - FF will regard it as a cross-site scripting violation.

So, if you have
and bar.xml pulls in "./baz.xsl" or "baz.xsl", it will work.

If you have
and bar.xml tries to pull in "../snafu/baz.xsl" or "file:///c/snafu/baz.xsl", it will fail as a cross-site scripting violation (I ran into this under Linux with the most recent versions of FF).

I think it will also fail if the path is an absolute (file:///c/foo/baz.xsl) even if the absolute directory is the same as the XML file's directory.

Return to Web Development / Standards Evangelism

Who is online

Users browsing this forum: No registered users and 0 guests