Using XSL Import to Find Relative File Paths on Windows

I have a simple XSL file that looks like this:

<?xml version='1.0'?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 

<xsl:import href="html/docbook.xsl"/> 

</xsl:stylesheet>  

I have an XSL file that is located in a folder on disk (not on the Internet). Its path relative to my XSL file (above):

..\..\..\Dependencies\XSL\xsl\htmlhelp\htmlhelp.xsl

<xsl:import href="..\..\..\Dependencies\XSL\xsl\htmlhelp\htmlhelp.xsl"/> 

or

<xsl:import href="../../../Dependencies/XSL/xsl/htmlhelp/htmlhelp.xsl"/> 

doesn't seem to work (I get - I can't find the files - errors from the xslproc tool.)

What is the correct way to write relative paths in XSL: import?

Thanks in advance,

Floor

+3
source share
4 answers

Of course, the forward slash characters are the ones to be used, i.e.

<xsl:import href="..\..\..\Dependencies\XSL\xsl\htmlhelp\htmlhelp.xsl"/>

is incorrect, no need to track this track.

, " URI" ( RFC 2396) , . , , URI, xslt.

XSLT 2.0, fn: base-uri(), , URI , .

+3

, , .

include/import Java: XSLT StreamSource SystemID, "where" XSLT .

http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=5

StreamSource, XSLT, commonFooter.xslt. , , URI. setSystemId() :

// construct a Source that reads from an InputStream
Source mySrc = new StreamSource(anInputStream);
// specify a system ID (a String) so the 
// Source can resolve relative URLs
// that are encountered in XSLT stylesheets
mySrc.setSystemId(aSystemId);

, , . , XSLT , cd - , , .

+5

I tested a simple import of styles using your relative path and xsltproc. This worked for me - so your relative path should be wrong.

+1
source

Use xsltproc -stringparam baseURI file: ///path/to/your/stylesheet.xsl -o result.xml stylesheet.xsl input.xml

-1
source

Source: https://habr.com/ru/post/1718099/


All Articles