Name

p:delete — The standard p:delete step.

Synopsis

The p:delete step deletes items specified by a selection pattern from the source input document and produces the resulting document, with the deleted items removed, on the result port.

Input portPrimarySequenceContent types
source✔  xml html 
Output portPrimarySequenceContent types
result✔  text xml html 
Option nameTypeRequired
matchXSLTSelectionPattern✔ 
Declaration
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
  |   <p:input port="source" content-types="xml html"/>
  |   <p:output port="result" content-types="text xml html"/>
  |   <p:option xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
5 |             name="match"
  |             required="true"
  |             as="xs:string"
  |             e:type="XSLTSelectionPattern"/>
  |</p:declare-step>
Errors
CodeDescription
err:XC0023It is a dynamic error (err:XC0023) if the match option matches the document node.
err:XC0062It is a dynamic error (err:XC0062) if the match option matches a namespace node.

Description

The p:delete step is defined in the XProc 3.0: Standard Step Library. It is also described on XProcRef.org.

Examples

Applied to the running example, this pipeline:

1 |<p:declare-step version="3.1"
  |                xmlns:p="http://www.w3.org/ns/xproc"
  |                xmlns:ex="https://xmlcalabash.com/ns/examples">
  |  <p:input port="source"/>
5 |  <p:output port="result"/>
  | 
  |  <p:delete match="//ex:chap/@class"/>
  | 
  |</p:declare-step>

Produces this output:

 1 |<?xml version="1.0" encoding="UTF-8"?><doc xmlns="https://xmlcalabash.com/ns/examples" xmlns:xi="http://www.w3.org/2001/XInclude" class="book">
   |  <chap former="1">
   |    <title>First Chapter</title>
   |    <p></p>
 5 |  </chap>
   |  <xi:include href="default-ch2.xml"/>
   |  <chap><title>Third Chapter</title>
   |  <p></p>
   |  </chap>
10 |  <app><title>Appendix</title>
   |  <p></p>
   |  </app>
   |</doc>

This listing attempts to summarize what has changed from the original input.

<doc xmlns="https://xmlcalabash.com/ns/examples"
     class="book">
<chap former="1" class="test">
<title>First Chapter</title>
<p>…</p>
</chap>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
            href="default-ch2.xml"/>
<chap>
<title>Third Chapter</title>
<p>…</p>
</chap>
<app>
<title>Appendix</title>
<p>…</p>
</app>
</doc>

When present, additions are shown in bold, green; deletions are shown in italic, red with strike through; and changed elements are shown in bold, italic orange.

 1 |<doc xmlns="https://xmlcalabash.com/ns/examples"
   |     xmlns:xi="http://www.w3.org/2001/XInclude"
   |     class="book">
   |  <chap former="1" class="test">
 5 |    <title>First Chapter</title>
   |    <p></p>
   |  </chap>
   |  <xi:include href="default-ch2.xml"/>
   |  <chap><title>Third Chapter</title>
10 |  <p></p>
   |  </chap>
   |  <app><title>Appendix</title>
   |  <p></p>
   |  </app>
15 |</doc>

The p:delete step can also delete elements:

1 |<p:declare-step version="3.1"
  |                xmlns:p="http://www.w3.org/ns/xproc"
  |                xmlns:ex="https://xmlcalabash.com/ns/examples">
  |  <p:input port="source"/>
5 |  <p:output port="result"/>
  | 
  |  <p:delete match="/ex:doc/ex:chap[1]"/>
  | 
  |</p:declare-step>

Produces this output:

 1 |<?xml version="1.0" encoding="UTF-8"?><doc xmlns="https://xmlcalabash.com/ns/examples" xmlns:xi="http://www.w3.org/2001/XInclude" class="book">
   |  
   |  <xi:include href="default-ch2.xml"/>
   |  <chap><title>Third Chapter</title>
 5 |  <p></p>
   |  </chap>
   |  <app><title>Appendix</title>
   |  <p></p>
   |  </app>
10 |</doc>

This listing attempts to summarize what has changed from the original input.

<doc xmlns="https://xmlcalabash.com/ns/examples"
     class="book">
<chap former="1" class="test">
<title>First Chapter</title>
<p>…</p>
</chap>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
            href="default-ch2.xml"/>
<chap>
<title>Third Chapter</title>
<p>…</p>
</chap>
<app>
<title>Appendix</title>
<p>…</p>
</app>
</doc>

When present, additions are shown in bold, green; deletions are shown in italic, red with strike through; and changed elements are shown in bold, italic orange.

 1 |<doc xmlns="https://xmlcalabash.com/ns/examples"
   |     xmlns:xi="http://www.w3.org/2001/XInclude"
   |     class="book">
   |  <chap former="1" class="test">
 5 |    <title>First Chapter</title>
   |    <p></p>
   |  </chap>
   |  <xi:include href="default-ch2.xml"/>
   |  <chap><title>Third Chapter</title>
10 |  <p></p>
   |  </chap>
   |  <app><title>Appendix</title>
   |  <p></p>
   |  </app>
15 |</doc>