Re: [xsl] unparsed-text-available a file from the current OS directory

Subject: Re: [xsl] unparsed-text-available a file from the current OS directory
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Sun, 29 Aug 2010 11:39:32 +0200
Or if you had an initial source socument and if it were in the current working directory, you could use
<xsl:variable name="current-base-uri" select="replace(base-uri(/), '[^/]+$', '')"/>


On 29.08.2010 11:19, Imsieke, Gerrit, le-tex wrote:

One way to make the current working directory known to the stylesheet is to pass it as a parameter:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0"> <xsl:output method="text"/> <xsl:param name="currentdir" /> <xsl:variable name="current-base-uri" select="concat('file:///', replace($currentdir, '\\', '/'))" /> <xsl:template name="main"> <xsl:sequence select="unparsed-text(concat($current-base-uri, '/', 'test.txt'))" /> </xsl:template> </xsl:stylesheet>


Suppose the stylesheet is c:\otherdir\test.xsl and there's a text file test.txt with contents 'TEST' in the current working directory.

Then:

C:\Users\gerrit>type test.txt
TEST

C:\Users\gerrit>java net.sf.saxon.Transform -xsl:c:/otherdir/test.xsl
-it:main currentdir=%CD%
TEST

I'm not sure I fully understood the requirement and whether there are
more 'canonical' ways to access the CWD in XSLT processors. (And I'm not
the Windows shell expert.) But I hope it is helpful anyway.

-Gerrit


On 29.08.2010 04:53, ac wrote:
Hi,

Sorry as this must have been answered before, but I have not yet found
the info.

With
<xsl:output method="text" indent="no"/>

if I use
<xsl:result-document href="boum.txt"> ...,

By default, boum.txt seems to get written to the "current" OS directory,
but if I do
<xsl:if test="unparsed-text-available('boum.txt')"> ...
boum.txt seems to get resolved from the base-uri (e.g. the stylesheet
directory path).

How can I have boum.text resolved from the current OS directory?

The objective is for processing files in the current OS directory (e.g.
from a batch (.bat) file, available from the PATH system variable, in
command-line mode), with a single instance of the stylesheet, sitting in
some other arbitrary directory.

Thank you,
ac



-- Gerrit Imsieke GeschC$ftsfC<hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard VC6ckler

Current Thread