Delete nodes in documents.
<p:declare-step type="p:delete"> <input port="source" primary="true" content-types="xml html" sequence="false"/> <output port="result" primary="true" content-types="text xml html" sequence="false"/> <option name="match" as="xs:string" required="true"/> </p:declare-step>
The p:delete
step deletes nodes, specified by an XSLT selection pattern, from the document appearing on its source
port.
Ports:
Type | Port | Primary? | Content types | Seq? | Description |
---|---|---|---|---|---|
|
|
|
|
| The document to delete the nodes from. |
|
|
|
|
| The resulting document. |
Options:
The p:delete
step takes the XSLT match pattern in the match
option and holds this against the document appearing on its
source
port. Any matching nodes are deleted (including child nodes, if any). The resulting document appears on the
result
port.
Note that deleting an element means that the entire element, including child elements, gets deleted. If you just want to delete the element
but keep its child elements, you need p:unwrap
.
The following example deletes all <text>
elements with an attribute type="normal"
from the source document.
Source document:
<texts> <text>Hello there!</text> <text>This is funny…</text> <text type="normal">And that's normal.</text> <text type="normal">Very normal…</text> </texts>
Pipeline document:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0"> <p:input port="source"/> <p:output port="result"/> <p:delete match="text[@type eq 'normal']"/> </p:declare-step>
Result document:
<texts> <text>Hello there!</text> <text>This is funny…</text> </texts>
p:delete
preserves all document-properties of the document(s) appearing on its source
port.
This step cannot remove namespaces, if you try this XC0023
is raised. For removing namespaces use p:namespace-delete
.
Deleting an xml:base
attribute does not change the base URI of the element on which it occurred.
This description of the p:delete
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:delete
step can be found here.
The p:delete
step is part of categories:
The p:delete
step is also present in version:
3.0.