The xtpxlib-common component contains the following XProc (1.0) library module:

Module/PipelineDescription
common.mod.xplXProc (1.0) library with generic steps.

3.1 XProc (1.0) library: common.mod.xpl

File: xplmod/common.mod/common.mod.xpl

XProc (1.0) library with generic steps.

PrefixNamespace URI
xtlchttp://www.xtpxlib.nl/ns/common
StepDescription
xtlc:copy-directoryCopies a full directory structure.
xtlc:copy-fileCopies a file, if necessary from inside a zip file.
xtlc:logWrites a message to a log file.
xtlc:recursive-directory-listReturns the contents of a directory, going into sub-directories recursively. When the requested directory does not exist, it returns only a c:directory root element with an error="true" attribute.
xtlc:remove-dirRemoves a full directory When the directory does not exist, everything continues without error.
xtlc:teeTees the input to a file and passes it unchanged (like the Unix tee command).
xtlc:zip-directoryZips a directory and its sub-directories into a single zip file.

3.1.1 Step: xtlc:copy-directory

Copies a full directory structure.

PortTypePrimary?Description
sourceinyesInput, will be passed unchanged.
resultoutyesThe input unchanged.
OptionRq?DefaultDescription
href-source-diryesReference to the directory to copy from (must have a leading file:/ specifier!).
href-target-diryesReference to the directory to copy to (must have a leading file:/ specifier!). If it does not exist the step will try to create it.

3.1.2 Step: xtlc:copy-file

Copies a file, if necessary from inside a zip file.

PortTypePrimary?Description
sourceinyesInput, will be passed unchanged.
resultoutyesThe input unchanged.
OptionRq?DefaultDescription
enable true()Whether the copying is done at all.
href-sourceyesReference to the source file to copy (must have a leading file:/ specifier!).
href-source-zip ''Document reference to a zip file (must have a leading file:/ specifier!). When filled, $href-source is assumed to be a path inside this zip.
href-targetyesReference to the target.

3.1.3 Step: xtlc:log

Writes a message to a log file.

PortTypePrimary?Description
sourceinyesInput to the logging, will be passed unchanged to the output
resultoutyesThe input unchanged.
OptionRq?DefaultDescription
enable true()Whether the logging will be done at all.
href-logyesName of the file to write the log messages to (must have a leading file:/ specifier!).
keep-messages 100The number of messages to keep in the logfile. If le 0, all messages are kept. Set by default to 100 to prevent overflowing files…
messageyesThe actual log message to write.
status 'ok'Status of the message. Must be ok, warning, error or debug.

3.1.4 Step: xtlc:recursive-directory-list

Returns the contents of a directory, going into sub-directories recursively. When the requested directory does not exist, it returns only a c:directory root element with an error="true" attribute.

Adapted from Norman Walsh's example code.

PortTypePrimary?Description
resultoutyesThe resulting directory structure listing in XML format.
OptionRq?DefaultDescription
depth -1The sub-directory depth to go. When le 0, all sub-directories are processed.
exclude-filter An optional regular expression exclude filter.
flatten false()When true, the list will be "flattened": All c:file children will be direct children of the root's c:directory element. These c:file elements get a @name, @href-abs (absolute filename) and @href-rel (relative filename) attribute.
include-filter An optional regular expression include filter.
pathyesThe path to get the directory listing from.

3.1.5 Step: xtlc:remove-dir

Removes a full directory When the directory does not exist, everything continues without error.

PortTypePrimary?Description
sourceinyesInput, will be passed unchanged.
resultoutyesThe input unchanged.
OptionRq?DefaultDescription
enable true()Whether the removal is done at all.
href-diryesReference to the directory to remove (must have a leading file:/ specifier!).

3.1.6 Step: xtlc:tee

Tees the input to a file and passes it unchanged (like the Unix tee command).

PortTypePrimary?Description
sourceinyesInput to the tee.
resultoutyesThe input unchanged (unless a $root-attribute-href was specified).
OptionRq?DefaultDescription
enable true()Whether to actually do the write. When false, nothing happens.
hrefyesName of the file to write to (must have a leading file:/ specifier!)
indent true()Whether or not to indent the tee-d output.
root-attribute-href ''If filled, $href is recorded as an attribute with this name on the root element of the original input. Must be a valid attribute name.

3.1.7 Step: xtlc:zip-directory

Zips a directory and its sub-directories into a single zip file.

PortTypePrimary?Description
resultoutyesThe output of the actual zip step, listing all the files that went in.
OptionRq?DefaultDescription
base-pathyesDirectory which contents will be stored in the zip (must have a leading file:/ specifier!)
href-target-zipyesDocument reference for the zip file to produce (must have a leading file:/ specifier!)
include-base true()When true, the last part of $base-path (e.g. a/b/c ==> c) is used as the root directory in the zip file.