XSL, get the current working directory

I am looking for a specific example of an XSL stylesheet storing the current working directory in a variable.

I need this because in my situation I need to import certain library style sheets using a relative path. Knowing the path that my processor chooses, since the current directory will be sufficient.

EDIT

Nothing special supplier.

+4
source share
2 answers

In XSLT 2.0, you can use the standard XPath 2.0 function resolve-uri () .

Please note that the relative URIs of the included / imported style sheets belong to the base URI of the style sheet enable / import module, and not from the "working directory"!

Here is a part of the description of this function from the W3 F & O specification:

8.1 fn: resolve-uri

fn: resolve-uri ($ relative as xs: string?) as xs: anyURI?

fn: resolve-uri ($ relative as xs: string ?, $ base as xs: string) as xs: anyURI

Summary: The purpose of this function is to allow the relative URI allowed against the absolute URI.

The first form of this function resolves the $ relative value of the base-uri property from a static context. If the underlying uri property is not initialized to a static context, an error occurs [ERR: FONS0005].

Here is a very simple example :

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:sequence select= "resolve-uri('resolve-uri-example2.xsl')"/> </xsl:template> </xsl:stylesheet> 

when this conversion is applied to any XML document (not used), the result :

 file:///c:/tests/resolve-uri-example2.xsl 

This is the correct result because our main stylesheet file is saved as:

 c:/tests/resolve-uri-example2.xsl 
+6
source

In the XSL world, there is no guarantee that an absolute current working directory exists or even that the concept makes sense. Any answer to this question will be specific to the supplier.

+2
source

All Articles