Subject:resolving URL in xml file Author:Alan Shiers Date:08 Aug 2005 07:01 PM Originally Posted: 08 Aug 2005 05:45 PM
I'm running a web application via servlets and jsp's on Tomcat.
Data is being stored in an MySQL database.
When I create an xml file using Java I store it in a field in the database.
The xml file contains the following prior to the DOCTYPE declaration:
<?xml version="1.0"?>
<?xml-stylesheet type="application/xml" href="http://localhost:8080/scholastic/stylesheets/test.xsl"?>
...
The test.xsl file is where the path says it is. When I view the
xml file in Netscape it finds the test.xsl file just fine and displays
things perfectly. But when I attempt to view the file in IE, all I
get is the raw xml file. For some reason, it can't see the test.xsl
file.
I've even moved the test.xsl file to other directories in the structure of my
application. But when I try to view the xml file, hoping IE
will be able to locate the test.xsl file, I still only
get the raw xml file displayed. I've tried using a
relative path: "scholastic/stylesheets/test.xsl" and even
just "test.xsl" but that didn't work either.
How do I set this up so that the test.xsl file is located?
Has anyone got any suggestions?
Alan
Subject:resolving URL in xml file Author:Alan Shiers Date:09 Aug 2005 07:09 PM
Hi there,
Ok, I made the change but unfortunately it made no difference. Once again Netscape didn't care. Netscape displayed the xml file using the xsl stylesheet no problem. But IE just keep cranking out:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Subject:resolving URL in xml file Author:Tony Lavinio Date:10 Aug 2005 08:58 AM
Try putting a copy of the .xsl and the .xml in the same directory on
the disk, and in the xml reference the file just by it's based name
(no path or protocol). Then use IE to find the file with File|Open,
and see what you get.
If this transforms properly, then the problem is most likely that
IE doesn't like the MIME type associated with the xsl file when it
is served from your webserver.
If this doesn't transform properly, then most likely there is something
wrong with the XSL installed with IE.
Subject:resolving URL in xml file Author:Alan Shiers Date:10 Aug 2005 10:39 AM
Hi there,
You know the old saying, "Can't see the forest for the trees?". Well, the answer was right under my nose all the time. But when you've been coding for several hours and frustrated, you sometimes just can't see the solution in front of you.
I tried your suggestion. It didn't work. Then I noticed something! The DOCTYPE declaration pointed to a dtd file named test.dtd. I had named the file tests.dtd (plural). I was hoping against hope that that little typo was all that was the matter. So I tried loading the xml file into IE again. WHALAAAA! That was it! It displayed properly.
Finally I was on to something. I returned to my project and corrected the error on the dtd string and left the relative URLs intact:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/scholastic/stylesheets/test.xsl"?>
<!DOCTYPE test SYSTEM "/scholastic/dtds/tests.dtd">
It worked! I did have to change the type declaration from "application/xml" to "text/xsl" to make it work properly however, thanks to your original suggestion.
Now I can move forward on my project. I posted this same problem on four other newsgroups and no one answered except you. In future, when I have a problem with xml, xsl technology, I'll know where to go to get the guidance needed.