title: XSLT transform child element to attribute in the parent
body: <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;parent id="38" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;child id="1" colorType="firstColor" colorKey="blue"/&gt;
    &lt;child id="2" colorType="secondColor" colorKey="red"/&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>So I have the previous XML and I would like to transform it, using XSLT, in the following way:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;parent id="38" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  firstColor="blue" secondColor="red"&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>So two values from the child element to be used as a pair attribute in the parent, removing the child element in the process. I tried but can't wrap my head around what seems to be the basics of XSLT.</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    &lt;xsl:template match="parent"&gt;
      &lt;parent&gt;
        &lt;xsl:apply-templates/&gt;
      &lt;/parent&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="parent"&gt;
      &lt;parent&gt;
        &lt;xsl:attribute name="{@colorType}"&gt;
          &lt;xsl:value-of select="@colorKey"/&gt;
        &lt;/xsl:attribute&gt;
       &lt;/parent&gt;
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>