I am trying to use VBScript to do an XSLT transform on an XML object.
The XSL file I'm translating includes the <xsl:import href="script.xsl"/>
directive. If I use the absolute URL (http://localhost/mysite/script.xsl
), it imports the style sheet fine; however, if I use the relative path (script.xsl
) it reports "resource not found." I need to be able to port this amongst a set of machines, so I need to be able to use the relative URI. Any suggestions?
Notes:
http://localhost/myscript.asp
http://localhost/mysite/styles.xsl
http://localhost/mysite/script.xsl
mysite/script.xsl
also does not workAddendum:
Thanks, everyone, for your answers. The more I dig into the code that is doing this, the stranger it is. myscript.asp
is a rather unusual compilation of code. What happens is styles.xsl
is included in the HTML output of myscript.asp
as an XML chunk (<xml src=...>
) and then that chunk is loaded as a stylesheet, using VBScript, on the client side. This stylesheet is then used to transform an XML chunk that is retrieved via XMLHTTP. So the problem is the context of styles.xsl
is the HTML on the client side and has no relation to where script.xsl
is.
The current directory for xsl:import, xsl:include, and the document() function is the directory containing the transform that uses them. So the xsl:import directive that you've said you're using ought to be working.
The only thing I can think of that might affect this: if you use a relative path, the file's being read directly from the file system, while if you use an absolute URI, it's being retrieved from the web server. Is it possible that there's some security setting that's preventing scripts from reading files in this directory?
@Jon I think you are very close... but shouldn't it be...
<xsl:import href="/mysite/script.xsl"/>
...with a leading slash?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With