expath-cg
expath-cg copied to clipboard
Several issues with EXPath File spec
I'm not 100% sure whether I should report it here or on the W3 mailing list for EXPath, if the latter is preferred, I can continue on the mailing list instead.
I found a few issues with the File Module (http://expath.org/spec/file) by glancing over it. Hopefully there's still room to address them (I may find more if I look deeper at the spec).
-
The functions
file:is-file
andfile:is-dir
: the description does not say whether it returns true only if there is an actual file (it uses the phrase "points to", but this is not specified and open for interpretation). If no file needs to physically exist, it is impossible to implement, because, for instance,file:is-file('c:\dir\test')
can be a file namedtest
or a dir namedtest
. If it isn't already created, then it is not possible to determine. The one exception is perhaps if there's a trailing slash or backslash. The same problem exists for XPath'sfn:resolve-uri
, which essentially removes the file part if and only if it ends in a trailing slash, but a URI has no notion of directory vs file. -
Several functions define an action that returns
empty-sequence()
. This may lead to problems for implementations, as in XPath, anything that returns an empty sequence can be optimized away. There's currently no section that explains how to deal with this special-casing of functions. Perhaps this could be solved by having them return a boolean instead, withfalse
on fail. Since it will also raise, this won't really change the behavior, and it potentially adds a feature on top where processors can allow an implementation defined setting to always return and not raise, for a try/catch free programming style. Alternatively, let them just return the input, or return the filename they are writing to. If such change is not an option, then I suggest we devote a section on explaining the expectations for implementors. -
Some functions seem under-specified, for instance,
file:create-temp-dir
has arguments$prefix
and$suffix
, but these are not explained in the text. And from the names I don't know what they are supposed to do. Same is true forfile:create-temp-file
-
A small chapter on encodings would be nice. Something like: implementers should support the same encodings as the hosting language (XQuery, XSLT), or just a minimum like in XPath: UTF8/16/ASCII.
-
It would be nice, if still possible, to make the 'current working directory' (CWD) dependent on the static base URI, or the current base URI (i.e. from
xml:base
) from XPath's DC or SC. Also, I'd suggest we add a line saying that CWD can be absent (i.e., if a processor runs in a protected env, or is created from a memory stream), in which most functions with relative paths would fail, while still allowing absolute paths. A processor can, of course, provide an option to set the CWD.
I apologize if these comments come too late in the process, I'm realizing you are close to publishing the Module to Final stage.