Concatenates text documents.
<p:declare-step type="p:text-join"> <input port="source" primary="true" content-types="text" sequence="true"/> <output port="result" primary="true" content-types="text" sequence="false"/> <option name="override-content-type" as="xs:string?" required="false" select="'text/plain'"/> <option name="prefix" as="xs:string?" required="false" select="()"/> <option name="separator" as="xs:string?" required="false" select="()"/> <option name="suffix" as="xs:string?" required="false" select="()"/> </p:declare-step>
The p:text-join
step takes the document(s) appearing on its source
port and concatenates these.
Ports:
Port | Type | Primary? | Content types | Seq? | Description |
---|---|---|---|---|---|
|
|
|
|
| The sequence of text documents to concatenate. |
|
|
|
|
| The resulting text document. |
Options:
The p:text-join
step takes the document(s) appearing on its source
port and concatenates these (in order of appearance).
Using the separator
, prefix
and suffix
options it is possible to insert additional
strings in between the documents, before the first document, or after the last document.
Assume we have three source text documents:
to-join-01.txt
First document to join!
to-join-02.txt
Second document to join! It's getting better…
to-join-03.txt
Third document to join! Last but not least!
Straight concatenation using p:text-join
looks like this:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0"> <p:input port="source" sequence="true"> <p:document href="to-join-1.txt"/> <p:document href="to-join-2.txt"/> <p:document href="to-join-3.txt"/> </p:input> <p:output port="result"/> <p:text-join/> </p:declare-step>
Result document:
First document to join! Second document to join! It's getting better… Third document to join! Last but not least!
And this is what happens if we use the separator
, prefix
and suffix
options:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0"> <p:input port="source" sequence="true"> <p:document href="to-join-1.txt"/> <p:document href="to-join-2.txt"/> <p:document href="to-join-3.txt"/> </p:input> <p:output port="result"/> <p:text-join separator="=========
" prefix="==START==
" suffix="==END==
"/> </p:declare-step>
Result document:
==START== First document to join! ========= Second document to join! It's getting better… ========= Third document to join! Last but not least! ==END==
Notice the use of the line-end character (line-feed, 

) in the option values. This will cause the inserted strings to
become separate lines.
When there are no documents on the source
port, the prefix
and suffix
options still
apply:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0"> <p:input port="source" sequence="true"> <p:empty/> </p:input> <p:output port="result"/> <p:text-join separator="=========
" prefix="==START==
" suffix="==END==
"/> </p:declare-step>
Result document:
==START== ==END==
No document-properties from the source document(s) survive. The joined document has no base-uri
document-property.
This operation does not require identifying lines. Therefore, no special end-of-line handling is performed.
This description of the p:text-join
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-join
step can be found here.
The p:text-join
step is part of categories:
The p:text-join
step is also present in version:
3.0.