title: What's the easiest way to trim out values from XML
body: <p>I have an XML document that have additonal nodes in it at different levels that I want to remove via XSLT.</p>
  
  <p>My intuition is to generate an XSD (using Altova or the like), remove the elements I don't want to appear in my output, then let the editor (Altova or the like) auto generate an XSLT to transform the old XSD into the new XSD.</p>
  
  <p>Back in the day, I used to write XSL for this by hand...but with all these cool tools, is there really a reason to or can someone suggest an alternative way? I haven't done this stuff in a couple of years, so I figured I would ask...</p>
  
  <p>I ended up coming up with this, which is pretty simple, so thanks for the suggestion:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" &gt;
  &lt;xsl:output method="xml" indent="yes"/&gt;
  
    &lt;xsl:template xpath-default-namespace="http://www.tempuri.org" 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 xpath-default-namespace="http://www.tempuri.org" match="SomeNode"&gt;
    &lt;/xsl:template&gt;
    &lt;xsl:template xpath-default-namespace="http://www.tempuri.org" match="TheNode[@type!='SomeType' and @type!='OtherType']"&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The one remaining thing I need to do is check for a missing element "SomeSubElement" of "TheNode" and insert an empty element if it's missing.</p>
  
  <p>Any suggestions on how to do this? Thanks.</p>