Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative path for xsl:import or xsl:include

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:

  • VBScript file is at http://localhost/myscript.asp
  • first XSL file is at http://localhost/mysite/styles.xsl
  • second XSL file is at http://localhost/mysite/script.xsl
  • using the relative path mysite/script.xsl also does not work

Addendum:

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.

like image 387
alumb Avatar asked Sep 26 '08 21:09

alumb


2 Answers

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?

like image 94
Robert Rossney Avatar answered Oct 12 '22 22:10

Robert Rossney


@Jon I think you are very close... but shouldn't it be...

<xsl:import href="/mysite/script.xsl"/>

...with a leading slash?

like image 1
dacracot Avatar answered Oct 12 '22 23:10

dacracot