title: Insert section into XML document
body: <p>I have this source XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SyncSupplierInvoice xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" languageCode="en-US" releaseID="9.2" systemEnvironmentCode="Production" versionID="2.8.0"&gt;
      &lt;UserArea&gt;
          &lt;Property&gt;
              &lt;NameValue name="TypeCode"&gt;PS&lt;/NameValue&gt;
          &lt;/Property&gt;
          &lt;Property&gt;
              &lt;NameValue name="TaxCode"&gt;TGPLG180&lt;/NameValue&gt;
          &lt;/Property&gt;
          &lt;Property&gt;
              &lt;NameValue name="TaxOrg"&gt;*&lt;/NameValue&gt;
          &lt;/Property&gt;
      &lt;/UserArea&gt;
  &lt;/SyncSupplierInvoice&gt;
  </code></pre>
  
  <p>There are <strong>3 Property</strong> sections in the UserArea. I want to insert a 4th section, <strong>customTaxCode</strong>, which contains last character of the TaxCode. Like so:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SyncSupplierInvoice xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" languageCode="en-US" releaseID="9.2" systemEnvironmentCode="Production" versionID="2.8.0"&gt;
      &lt;UserArea&gt;
          &lt;Property&gt;
              &lt;NameValue name="TypeCode"&gt;PS&lt;/NameValue&gt;
          &lt;/Property&gt;
          &lt;Property&gt;
              &lt;NameValue name="TaxCode"&gt;TGPLG180&lt;/NameValue&gt;
          &lt;/Property&gt;
          &lt;Property&gt;
              &lt;NameValue name="customTaxCode"&gt;0&lt;/NameValue&gt;
          &lt;/Property&gt;
          &lt;Property&gt;
              &lt;NameValue name="TaxOrg"&gt;*&lt;/NameValue&gt;
          &lt;/Property&gt;
      &lt;/UserArea&gt;
  &lt;/SyncSupplierInvoice&gt;
  </code></pre>
  
  <p>My XSLT is only working partially. The problem is that it creates the Property elements under the existing Property element, rather than as a sibling. I am not sure how to achieve the result. Thank you in advance for any advice.</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://schema.infor.com/InforOAGIS/2" xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java"&gt;
      &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /&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="//my:UserArea/my:Property/my:NameValue[@name='TaxCode']"&gt;
        &lt;xsl:copy-of select="."/&gt;
      &lt;Property&gt;
          &lt;NameValue name="customTaxCode"&gt;
              &lt;xsl:value-of select="substring(., string-length(.), 1)" /&gt;
          &lt;/NameValue&gt;
      &lt;/Property&gt;
     &lt;/xsl:template&gt; 
  &lt;/xsl:stylesheet&gt;
  </code></pre>