title: I need to trim the payload using XSLT 1.0
body: <p>I am having a payload as below </p>
  
  <pre><code>&lt;order&gt;
      &lt;ordernumber&gt;1-123
      &lt;/ordernumber&gt;
      &lt;orderline&gt;
          &lt;linenumber&gt;root
          &lt;/linenumber&gt;
          &lt;parentnumber&gt;
          &lt;/parentnumber&gt;
          &lt;type&gt;order
          &lt;/type&gt;
          &lt;actioncode&gt;Existing
          &lt;/actioncode&gt;
      &lt;/orderline&gt;
      &lt;orderline&gt;
          &lt;linenumber&gt;x1
          &lt;/linenumber&gt;
          &lt;parentnumber&gt;root
          &lt;/parentnumber&gt;
          &lt;type&gt;Bundle
          &lt;/type&gt;
          &lt;actioncode&gt;Existing
          &lt;/actioncode&gt;
      &lt;/orderline&gt;
      &lt;orderline&gt;
          &lt;linenumber&gt;xsub1
          &lt;/linenumber&gt;
          &lt;parentnumber&gt;x1
          &lt;/parentnumber&gt;
          &lt;type&gt;Bundle
          &lt;/type&gt;
          &lt;actioncode&gt;Existing
          &lt;/actioncode&gt;
      &lt;/orderline&gt;
      &lt;orderline&gt;
          &lt;linenumber&gt;xsub2
          &lt;/linenumber&gt;
          &lt;parentnumber&gt;x1
          &lt;/parentnumber&gt;
          &lt;type&gt;Bundle
          &lt;/type&gt;
          &lt;actioncode&gt;ADD
          &lt;/actioncode&gt;
      &lt;/orderline&gt;
      &lt;orderline&gt;
          &lt;linenumber&gt;xsub3
          &lt;/linenumber&gt;
          &lt;parentnumber&gt;x1
          &lt;/parentnumber&gt;
          &lt;type&gt;Bundle
          &lt;/type&gt;
          &lt;actioncode&gt;Existing
          &lt;/actioncode&gt;
      &lt;/orderline&gt;
  &lt;/order&gt;
  </code></pre>
  
  <p>I want to keep only <code>orderline = ADD</code> and its parent order line as below </p>
  
  <pre><code>&lt;order&gt;
      &lt;ordernumber&gt;1-123
      &lt;/ordernumber&gt;
      &lt;orderline&gt;
          &lt;linenumber&gt;x1
          &lt;/linenumber&gt;
          &lt;parentnumber&gt;root
          &lt;/parentnumber&gt;
          &lt;type&gt;Bundle
          &lt;/type&gt;
          &lt;actioncode&gt;Existing
          &lt;/actioncode&gt;
      &lt;/orderline&gt;
      &lt;orderline&gt;
          &lt;linenumber&gt;xsub2
          &lt;/linenumber&gt;
          &lt;parentnumber&gt;x1
          &lt;/parentnumber&gt;
          &lt;type&gt;Bundle
          &lt;/type&gt;
          &lt;actioncode&gt;ADD
          &lt;/actioncode&gt;
      &lt;/orderline&gt;
  &lt;/order&gt;
  </code></pre>
  
  <p>I tried using identity function but could not figure out the logic....
  can you please help me 
  thanks in advance </p>
  
  <p>This what I have tried, but am unable to figure out how to get the parent line item of Xsub2 where <code>actioncode = 'ADD'</code></p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0"    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:template match="@*|node()"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:apply-templates select="@*|node()"/&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match="/order/orderline[actioncode !='ADD']"/&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>