title: copy element with attribute and namespace xslt
body: <p>Hi i have an xml and i would copy the top root element of the xml with all atributes and namespace and copy it under the UserArea tag of the same xml.
  my xml is this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SyncShipment xmlns="http://schema.infor.com/InforOAGIS/2" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2  http://schema.infor.com/2.6.3/InforOAGIS/BODs/Developer/SyncShipment.xsd" 
  versionID="2.6.3" releaseID="9.2" systemEnvironmentCode="Production" languageCode="en-US"&gt;
  &lt;ApplicationArea&gt;
      &lt;Sender&gt;
          &lt;LogicalID schemeVersionID="VMSHPENT:7.0.0.156:AC7726D2"&gt;lid://infor.visual.visual&lt;/LogicalID&gt;
          &lt;ComponentID&gt;Visual&lt;/ComponentID&gt;
          &lt;ConfirmationCode&gt;OnError&lt;/ConfirmationCode&gt;
      &lt;/Sender&gt;
      &lt;CreationDateTime&gt;2015-03-04T09:25:12.107Z&lt;/CreationDateTime&gt;
      &lt;BODID location="Site~Gouda" schemeAgencyName="Visual"&gt;infor-nid:infor:NKFEX:Site~Gouda:Shipper~S14-01709~1:?Shipment&amp;#38;verb=Sync&lt;/BODID&gt;
  &lt;/ApplicationArea&gt;
  &lt;DataArea&gt;
      &lt;ShipmentHeader&gt;
          &lt;UserArea&gt;
                  &lt;Property&gt;
                      &lt;NameValue name="visual.UserDefined1" type="String"/&gt;
                  &lt;/Property&gt;
                  &lt;Property&gt;
                      &lt;NameValue name="visual.UserDefined2" type="String"/&gt;
                  &lt;/Property&gt;
                  &lt;/UserArea&gt;     
          &lt;/ShipmentHeader&gt;
      &lt;/DataArea&gt;
  &lt;/SyncShipment&gt;
  </code></pre>
  
  <p>if i apply this xslt</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://schema.infor.com/InforOAGIS/2"   xmlns:a="http://schema.infor.com/InforOAGIS/2" exclude-result-prefixes="a" version="1.0"&gt;
  &lt;xsl:output indent="yes"/&gt;
  &lt;xsl:template match="*|@*"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="node()|@*"/&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template match="//a:ShipmentHeader/a:UserArea/a:Property[last()]"&gt;
      &lt;xsl:copy-of select="."/&gt;
      &lt;xsl:variable name="apparea" select="//a:SyncShipment"/&gt;
      &lt;Property&gt;
      &lt;NameValue name="app" type="xml"&gt;
  &lt;xsl:copy-of select="$apparea"/&gt;
      &lt;/NameValue&gt;
      &lt;/Property&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p></p>
  
  <p>i got another property tag within the UserArea but with the entire xml itself. on the contrary i would have an xml where in the 3rd property tag in the UserArea tag i have just the root node of the SyncShipment like this</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;SyncShipment xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 http://schema.infor.com/2.6.3/InforOAGIS/BODs/Developer/SyncShipment.xsd" versionID="2.6.3" releaseID="9.2" systemEnvironmentCode="Production" languageCode="en-US"&gt;
    &lt;ApplicationArea&gt;
      &lt;Sender&gt;
        &lt;LogicalID schemeVersionID="VMSHPENT:7.0.0.156:AC7726D2"&gt;lid://infor.visual.visual&lt;/LogicalID&gt;
        &lt;ComponentID&gt;Visual&lt;/ComponentID&gt;
        &lt;ConfirmationCode&gt;OnError&lt;/ConfirmationCode&gt;
      &lt;/Sender&gt;
      &lt;CreationDateTime&gt;2015-03-04T09:25:12.107Z&lt;/CreationDateTime&gt;
      &lt;BODID location="Site~Gouda" schemeAgencyName="Visual"&gt;infor-nid:infor:NKFEX:Site~Gouda:Shipper~S14-01709~1:?Shipment&amp;amp;verb=Sync&lt;/BODID&gt;
    &lt;/ApplicationArea&gt;
    &lt;DataArea&gt;
      &lt;ShipmentHeader&gt;
        &lt;UserArea&gt;
          &lt;Property&gt;
            &lt;NameValue name="visual.UserDefined1" type="String"/&gt;
          &lt;/Property&gt;
          &lt;Property&gt;
            &lt;NameValue name="visual.UserDefined2" type="String"/&gt;
          &lt;/Property&gt;
          &lt;Property&gt;
            &lt;NameValue name="app" type="xml"&gt;
              &lt;SyncShipment xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 http://schema.infor.com/2.6.3/InforOAGIS/BODs/Developer/SyncShipment.xsd" versionID="2.6.3" releaseID="9.2" systemEnvironmentCode="Production" languageCode="en-US"&gt;
            &lt;/NameValue&gt;
          &lt;/Property&gt;
        &lt;/UserArea&gt;
      &lt;/ShipmentHeader&gt;
    &lt;/DataArea&gt;
  &lt;/SyncShipment&gt;
  </code></pre>