xsl-list
[Top] [All Lists]

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

2010-08-29 04:20:06

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


--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--
Gerrit Imsieke
Geschäftsfü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(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

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

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--