title: XSLT select part of XML message
body: <p>I'm strugling to find a solution to an XML message extract problem.
  What I have is a similar with below XML message:</p>
  
  <pre><code>&lt;Orders xmlns="http://AU.InputOrders"&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004451&lt;/OrderRef&gt;
  &lt;OrderQty&gt;5&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004451&lt;/OrderRef&gt;
  &lt;OrderQty&gt;1&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004452&lt;/OrderRef&gt;
  &lt;OrderQty&gt;1&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004452&lt;/OrderRef&gt;
  &lt;OrderQty&gt;4&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004452&lt;/OrderRef&gt;
  &lt;OrderQty&gt;2&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;/Orders&gt;
  </code></pre>
  
  <p>I need an XSLT to get this bit only:</p>
  
  <pre><code>&lt;Orders xmlns="http://AU.InputOrders"&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004451&lt;/OrderRef&gt;
  &lt;OrderQty&gt;5&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004451&lt;/OrderRef&gt;
  &lt;OrderQty&gt;1&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;/Orders&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;Orders xmlns="http://AU.InputOrders"&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004452&lt;/OrderRef&gt;
  &lt;OrderQty&gt;1&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004452&lt;/OrderRef&gt;
  &lt;OrderQty&gt;4&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;Order&gt;
  &lt;OrderRef&gt;D04004452&lt;/OrderRef&gt;
  &lt;OrderQty&gt;2&lt;/OrderQty&gt;
  &lt;/Order&gt;
  &lt;/Orders&gt;
  </code></pre>
  
  <p>In other words, I need to retrieve Order parts based on OrderRef element value.</p>
  
  <p>Thanks.</p>
  
  <p>Tried both below solution and both works.
  Did find another solution which works as well. It doesn't use OrderRef but the position of the Order elements. Still this one is doing what I needed.</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:ns0="http://AU.InputOrders"&gt;
  &lt;xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="no"/&gt;
  &lt;xsl:template match="/"&gt;
     &lt;xsl:element name="Orders" namespace="http://AU.InputOrders"&gt;
     &lt;xsl:copy-of select="ns0:Orders/ns0:Order[position() &amp;gt;= 1 and position() &amp;lt;=2]"/&gt;
     &lt;/xsl:element&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Thanks.</p>