title: XSLT select by child node value
body: <p>I am trying to process an XML file with XSLT, where I need to select nodes by  child value. I tried to simple filter out results by regex, but maybe it is not the most elegant way to do this. I think XSLT is an universal solution to do this transform, if not please suggest me a better solution. The XML file actually look like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1250"?&gt;
  &lt;SHOP&gt;
  &lt;SHOPITEM&gt;
  &lt;unknown_element1&gt;&lt;/unknown_element1&gt;
  &lt;unknown_element2&gt;&lt;/unknown_element2&gt;
  ...
  &lt;YEAR&gt;2015&lt;/YEAR&gt;
  &lt;unknown_elementxy&gt;&lt;/unknown_elementxy&gt;
  ...
  &lt;/SHOPITEM&gt;
  &lt;SHOPITEM&gt;
  &lt;unknown_element1&gt;&lt;/unknown_element1&gt;
  &lt;unknown_element2&gt;&lt;/unknown_element2&gt;
  ...
  &lt;YEAR&gt;2014&lt;/YEAR&gt;
  &lt;unknown_elementxy&gt;&lt;/unknown_elementxy&gt;
  ...
  &lt;/SHOPITEM&gt;
  &lt;SHOPITEM&gt;
  &lt;unknown_element1&gt;&lt;/unknown_element1&gt;
  &lt;unknown_element2&gt;&lt;/unknown_element2&gt;
  ...
  &lt;YEAR&gt;2015&lt;/YEAR&gt;
  &lt;unknown_elementxy&gt;&lt;/unknown_elementxy&gt;
  ...
  &lt;/SHOPITEM&gt;
  &lt;/SHOP&gt;
  </code></pre>
  
  <p>I want to keep current XML structure, but keep only nodes where  = 2015. The desidered output:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="windows-1250"?&gt;
  &lt;SHOP&gt;
  &lt;SHOPITEM&gt;
  &lt;unknown_element1&gt;&lt;/unknown_element1&gt;
  &lt;unknown_element2&gt;&lt;/unknown_element2&gt;
  ...
  &lt;YEAR&gt;2015&lt;/YEAR&gt;
  &lt;unknown_elementxy&gt;&lt;/unknown_elementxy&gt;
  ...
  &lt;/SHOPITEM&gt;
  &lt;SHOPITEM&gt;
  &lt;unknown_element1&gt;&lt;/unknown_element1&gt;
  &lt;unknown_element2&gt;&lt;/unknown_element2&gt;
  ...
  &lt;YEAR&gt;2015&lt;/YEAR&gt;
  &lt;unknown_elementxy&gt;&lt;/unknown_elementxy&gt;
  ...
  &lt;/SHOPITEM&gt;
  &lt;/SHOP&gt;
  </code></pre>
  
  <p><code>&lt;unknown_element&gt;</code> = there are many different elements in the node, the XSLT should keep current structure of the actual node. Just need to filter out nodes by <code>&lt;YEAR&gt;</code>.</p>
  
  <p>I am trying something like this:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
   &lt;xsl:output omit-xml-declaration="no" indent="yes" method="xml"/&gt;
  
   &lt;xsl:template match="//SHOPITEM[YEAR=2015]"&gt;
       &lt;xsl:copy&gt;
         &lt;xsl:apply-templates select="node()|@*"/&gt;
       &lt;/xsl:copy&gt;
   &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>