RE: why not in p:exec ... ""If cwd is not specified, the cwd is the same as the xproc file one is running."?

Good points norm.
To add one more.  Let us not forget the decades of historical precidence
learned by the 'school of hard knocks' .    Very often its more useful (and
more secure)
for the "CWD" of sub-procs in systems that support a CWD to be that of the
calling environment, NOT that of the script. 
Example, suppose you put a script in /usr/scripts/coolscript.xproc

that runs through all *.xml files *in your current directory* ...
The intent is it works on the CWD of the caller not where the script is
This keeps a good issolation of code and data. "as it should be".

Of course there are use case where this is not ideal ... but over the
decades this pattern has been found to be "a good thing"

David A. Lee

-----Original Message-----
From: Norman Walsh [] 
Sent: Wednesday, January 18, 2012 7:01 AM
To: XProc Dev
Subject: Re: why not in p:exec ... ""If cwd is not specified, the cwd is the
same as the xproc file one is running."?

Alex Muir <> writes:
> Thanks for the simpler way and the explanation, although other steps
> seem to rely on a concept of cwd being the directory the xproc file
> is in for example xslt files are referenced as relative to the
> location of the xproc file so I'm not clear on the reasons p:exec
> would differ from those and a bit interested to know why as I assume
> there is a reason.

Most XML tools resolve links relative to the base URI of some element.
That's the way that href links in XProc and XSLT files work, for example.
Those steps can fail if there is no base URI.

The spec could have said that the CWD for p:exec should be the same
directory as the directory that contains the XProc pipeline document,

1. What about pipelines that are accessed by http?
2. What about pipelines that arrive on stdin?
3. What about operating environments that have no concept of a CWD?

The spec could have said "should" I suppose with caveats.

But there's also the question of whether or not that's the right thing.

The build script for my XProc book uses p:exec and relies on the fact
that "bin/" will do the right thing. I could have written
it so that "../bin/" would do the right thing, of course,
but then has to be changed to look in ".." for config files
and such, at least potentially.

The p:exec step has a cwd option; you can certainly write your own pipeline
library that contains my:exec that does the exact same thing as p:exec
it sets the cwd option appropriately.

                                        Be seeing you,

Norman Walsh
Lead Engineer
MarkLogic Corporation
Phone: +1 413 624 6676

Received on Wednesday, 18 January 2012 12:14:43 UTC