Previous Up Next


p:delete

p:delete — Deletes matching nodes.

Synopsis

<p:declare-step type="p:delete">
     <p:input port="source"/>
     <p:output port="result"/>
     <p:option name="match" required="true"/>                      <!-- XSLTMatchPattern -->
</p:declare-step>

Description

The p:delete step deletes elements, attributes, processing instructions or text nodes that match the specified pattern. It cannot remove namespace nodes.

If an element is selected by the match option, the entire subtree rooted at that element is deleted.

If an attribute named xml:base is deleted, that does not change the base URI of the element on which it occurred.

Errors

Error Description
err:C0062 Occurs if the match option matches a namespace node.

Examples

This pipeline deletes elements with a class attribute that contains the string “del”.

  1 <p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:h="http://www.w3.org/1999/xhtml"
                version="1.0">
    
  5   <p:delete match="*[contains(@class,'del')]"/>
    </p:pipeline>
Input Output
1 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Some Document</title>
</head>
5 <body>
<div>
<p class="add">This is new text.</p>
<p class="del">Some text.</p>
<div>
10 <pre class="chg">Some pre text.</pre>
</div>
</div>
<div class="del strikeout">
<pre>Some more example pre text.</pre>
15 </div>
</body>
</html>
 
1 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Some Document</title>
</head>
5 <body>
<div>
<p class="add">This is new text.</p>
<p class="del">Some text.</p>
<div>
<pre class="chg">Some pre text.</pre>
10 </div>
</div>
<div class="del strikeout">
<pre>Some more example pre text.</pre>
</div>
</body>
</html>

Multiple deletes can be accomplished by pipelining several p:delete steps. This pipeline removes all the change markup.

  1 <p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:h="http://www.w3.org/1999/xhtml"
                version="1.0">
    
  5   <p:delete match="*[contains(@class,'del')]"/>
    
      <p:delete match="*[contains(@class,'add')]/@class"/>
    
      <p:delete match="*[contains(@class,'chg')]/@class"/>
 10 </p:pipeline>
Input Output
1 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Some Document</title>
</head>
5 <body>
<div>
<p class="add">This is new text.</p>
<p class="del">Some text.</p>
<div>
10 <pre class="chg">Some pre text.</pre>
</div>
</div>
<div class="del strikeout">
<pre>Some more example pre text.</pre>
15 </div>
</body>
</html>
 
1 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Some Document</title>
</head>
5 <body>
<div>
<p>This is new text.</p>
<p class="del">Some text.</p>
<div>
<pre>Some pre text.</pre>
10 </div>
</div>
<div class="del strikeout">
<pre>Some more example pre text.</pre>
</div>
</body>
</html>