Re: Getting the current working directory

Hi Patrick,

On Wed, 25 Oct 2017 14:44:12 +0200,
Patrick Gundlach wrote:
> 
> Hello David,
> 
> thank you for the answer, it looks promising. But I have to admit
> that I have now clue how to add this to my pipeline, which is
> something like
>
> ...
>

<p:declare-step
    xmlns:p="http://www.w3.org/ns/xproc"
    xmlns:pos="http://exproc.org/proposed/steps/os"
    xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">

  <p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl"/>

  <pos:info/>
  <p:group>
    <p:variable name="cwd" select="translate(/c:result/@cwd, '\', '/')"/>
  
    <p:xslt name="Transformation">
      <p:with-param name="somefile" select="concat('file:/', $cwd, '/somefile.xml')">
        <p:empty/>
      </p:with-param>
      <p:input port="source">
        <p:document href="source.xml"/>
      </p:input>
      <p:input port="stylesheet">
        <p:document href="transformation.xsl"/>
      </p:input>
    </p:xslt>

    <p:store href="data.xml"/>
  </p:group>
  
</p:declare-step>

See also https://gist.github.com/dmj/004a1cff89ba7e07a626c41037af6f4e

I p:import the Calabash extension library in order to use the pos:info
step.

pos:info creates a document that flows into the p:group where I
capture the current working directory as a variable. Because this
pipeline runs on windows and the XSLT requires a URI to access the
stylesheet I replace the backslash with the forward slash.

I then construct a URI with the full path to 'somefile.xml' and pass
this URI to the stylesheet.

IIRC the p:group is required because in XProc 1.0 you can only define
variables at the beginning of a subpipeline.

HTH,
  -- David

-- 
David Maus M.A.
Okerstraße 5 ~ 38300 Wolfenbüttel ~ GERMANY
http://dmaus.name
PGP Key 0x27023DFCE78FF66C

Received on Wednesday, 25 October 2017 13:12:55 UTC