Returns lines from the end of a text document.
<p:declare-step type="p:text-tail"> <input port="source" primary="true" content-types="text" sequence="false"/> <output port="result" primary="true" content-types="text" sequence="false"/> <option name="count" as="xs:integer" required="true"/> </p:declare-step>
The p:text-tail
step returns lines from the end of a text document.
Ports:
Type | Port | Primary? | Content types | Seq? | Description |
---|---|---|---|---|---|
|
|
|
|
| The text document to get the lines from. |
|
|
|
|
| The resulting lines. |
Options:
The p:text-tail
step takes lines from the end of the text document appearing on its source
port and returns these lines as a text
document on its result
port. What exactly happens depends on the value of the count
option.
As you might have guessed there is also a step that returns lines from the beginning of a document: p:text-head
.
Assume we have a text document, called lines.txt
, that looks like this and we want to get the last 2 lines using
p:text-tail
:
line 1 line 2 line 3 line 4 line 5
Pipeline document:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0"> <p:input port="source" href="lines.txt"/> <p:output port="result"/> <p:text-tail count="2"/> </p:declare-step>
Result document:
line 4 line 5
Setting the count
option to 0
will simply return the original document (the step now acts like a p:identity
step).
Setting the count
option to -2
will return all lines except the last
two:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0"> <p:input port="source" href="lines.txt"/> <p:output port="result"/> <p:text-tail count="-2"/> </p:declare-step>
Result document:
line 1 line 2 line 3
p:text-tail
preserves all document-properties of the document(s) appearing on its source
port.
What exactly constitutes a line-end is defined in the XML specification.
All lines returned by p:text-tail
are terminated with a line-end character (line-feed, 

).
This description of the p:text-tail
step is for XProc version: 3.0. This is a required step (an XProc 3.0 processor must support this).
The formal specification for the p:text-tail
step can be found here.
The p:text-tail
step is part of categories:
The p:text-tail
step is also present in version:
3.1.