title: How to copy specific attribute using XSLT?
body: <p>Apologies for the basic nature of these questions - I'm brand new to XSLT (and to Stack Overflow too).</p>
  
  <p>I need to transform the following XML being returned by a Sharepoint Web service:</p>
  
  <pre><code>&lt;GetGroupCollectionFromUser xmlns=
     "http://schemas.microsoft.com/sharepoint/soap/directory/"&gt;
     &lt;Groups&gt;
        &lt;Group ID="3" Name="Group1" Description="Description" OwnerID="1" 
           OwnerIsUser="False" /&gt;
        &lt;Group ID="15" Name="Group2" Description="Description" 
           OwnerID="12" OwnerIsUser="True" /&gt;
        &lt;Group ID="16" Name="Group3" Description="Description" 
           OwnerID="7" OwnerIsUser="False" /&gt;
     &lt;/Groups&gt;
  &lt;/GetGroupCollectionFromUser&gt;
  </code></pre>
  
  <p>into this:</p>
  
  <pre><code>&lt;GetGroupCollectionFromUser xmlns=
     "http://schemas.microsoft.com/sharepoint/soap/directory/"&gt;
     &lt;Groups&gt;
        &lt;Group Name="Group1" /&gt;
        &lt;Group Name="Group2" /&gt;
        &lt;Group Name="Group3" /&gt;
     &lt;/Groups&gt;
  &lt;/GetGroupCollectionFromUser&gt;
  </code></pre>
  
  <p>Basically, I need to drop all the attributes for each Group element except Name. After a lot of research and tinkering, and notably dropping the namespace declaration from the original XML, I've come up with something that gets me almost exactly what I need:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:output method="xml" encoding="utf-8" indent="no"/&gt;
  
  &lt;xsl:template match="/GetGroupCollectionFromUser"&gt;
      &lt;xsl:copy&gt;                  
          &lt;xsl:apply-templates select="Groups" /&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="Groups"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="Group" /&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt; 
  
  &lt;xsl:template match="Group"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@Name" /&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>However, instead of a Name attribute, the above gives me the value of the Name attribute inserted as text into the Group element, like so:</p>
  
  <pre><code>&lt;GetGroupCollectionFromUser&gt;
      &lt;Groups&gt;
          &lt;Group&gt;Group1&lt;/Group&gt;
          &lt;Group&gt;Group2&lt;/Group&gt;
          &lt;Group&gt;Group3&lt;/Group&gt;
      &lt;/Groups&gt;
  &lt;/GetGroupCollectionFromUser&gt;
  </code></pre>
  
  <p>This will ultimately be consumed by a third-party application that's expecting attribute-centric XML. I'm sure I'm missing something embarrassingly obvious, but no matter what I do with it I can't seem to pull in just the Name attribute. Two questions:</p>
  
  <p>How do I alter the XSLT to return a Name attribute for each Group element, instead of its value as text?</p>
  
  <p>And, how do I handle the namespace properly? When I've included it in the XSLT, trying several methods based on examples I've found here and elsewhere on the web, I get nothing at all back. </p>
  
  <p>Thanks in advance for any advice.</p>