Counts the number of lines in a text document.
<p:declare-step type="p:text-count"> <input port="source" primary="true" content-types="text" sequence="false"/> <output port="result" primary="true" content-types="application/xml" sequence="false"/> </p:declare-step>
The p:text-count
step counts the number of lines in the text document appearing on its source
port and returns an XML document on
its result
port containing that number.
Ports:
Type | Port | Primary? | Content types | Seq? | Description |
---|---|---|---|---|---|
|
|
|
|
| The text document to count the lines of. |
|
|
|
|
| An XML document consisting of a single Example: |
The p:text-count
step simply counts the number of lines in the text document appearing on its source
port. This number is returned
on the result
port, wrapped in an <c:result>
element.
Assume we have a text document, called lines.txt
, that looks like this and we want to count the number of lines using
p:text-count
:
line 1 line 2 line 3
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-count/> </p:declare-step>
Result document:
<c:result xmlns:c="http://www.w3.org/ns/xproc-step">3</c:result>
No document-properties from the document on the source
port survives. The resulting document has a
content-type
document-property set to application/xml
and no base-uri
document-property.
What exactly constitutes a line-end is defined in the XML specification.
If the very last character of the source document is a line-end, this is ignored. So it does not count as a separator between that line and a following line (that contains no characters).
This description of the p:text-count
step is for XProc version: 3.1. This is a required step (an XProc 3.1 processor must support this).
The formal specification for the p:text-count
step can be found here.
The p:text-count
step is part of categories:
The p:text-count
step is also present in version:
3.0.