The moose likes XML and Related Technologies and the fly likes xml-stylesheet href= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml-stylesheet href="??"" Watch "xml-stylesheet href="??"" New topic

xml-stylesheet href="??"

Chris Gage

Joined: Mar 23, 2005
Posts: 17

I have a set of XML pages that I am developing, along with an XSL stylesheet that will render the pages to XHTML on the browser. If I use a stylesheet reference of the following form, with the XSL in the same folder as all the XML files, it works correctly:

<?xml-stylesheet type="text/xsl" href="project.xsl"?>

But when my project grows, I will have many folders on different subjects, all of them using the same XSL, so I would want to put the XSL in the parent folder and use the normal ../foo reference:

<?xml-stylesheet type="text/xsl" href="../project.xsl"?>

But when I move it there and try this, my XSL doesn't work. Is there some special incantation for referencing the parent folder in this case?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I'm just guessing, but generally browsers frown on that "parent folder" abbreviation because it can be used to go fishing outside the web domain from which the original resource was loaded. So perhaps it's being treated as a security violation. Not sure how you would confirm that guess, though.
Chris Gage

Joined: Mar 23, 2005
Posts: 17

That sounds reasonable. Does that mean I should put a full url reference in there, something like...

<?xml-stylesheet type="text/xsl" href=""?>

If the above is the correct and approved way to do it, I'll adopt it. It makes testing the site rather a hassle, since I am using Eclipse WTP and it imposes the workspace/project/WebContent structure, which goes away when the site is deployed to the webserver.
I agree. Here's the link:
subject: xml-stylesheet href="??"
It's not a secret anymore!