Modify XML: attributes into elements
You can shred the XML and rebuild it again using XQuery.

declare @X xml = '
&lt;Root attr1="val1" attr2="val2"&gt;
    &lt;Elements&gt;
        &lt;Element Code="1" Value="aaa" ExtraData="extra" /&gt;
        &lt;Element Code="2" Value="" ExtraData="extra" /&gt;
        &lt;Element Code="3" ExtraData="extra" /&gt;
    &lt;/Elements&gt;
    &lt;ExtraData&gt;
       &lt;!-- Some XML is here --&gt;
    &lt;/ExtraData&gt;
&lt;/Root&gt;';

select @X.query('
  (: Create element Root :)
  element Root 
    {
      (: Add all attributes from Root to Root :)
      /Root/@*, 
      (: create element Elements under Root :)
      element Elements 
        {
          (: For each Element element in /Root/Elements :)
          for $e in /Root/Elements/Element
          return 
            (: Add element Element :)
            element Element 
              {
                (: Add all attributes except Value to Element :)
                $e/@*[local-name() != "Value"], 

                (: Check if Attribute Value exist :)
                if (data($e/@Value) != "")
                then
                  (: Create a Value element under Element :)
                  element Value 
                  {
                    (: Add attribute Value as data to the element Element :)
                    data($e/@Value)
                  }
                else () (: Empty element :)
              } 
          },
      (: Add all childelements to Root except the Elements element :)
      /Root/*[local-name() != "Elements"]
    }');


Result:

&lt;Root attr1="val1" attr2="val2"&gt;
  &lt;Elements&gt;
    &lt;Element Code="1" ExtraData="extra"&gt;
      &lt;Value&gt;aaa&lt;/Value&gt;
    &lt;/Element&gt;
    &lt;Element Code="2" ExtraData="extra" /&gt;
    &lt;Element Code="3" ExtraData="extra" /&gt;
  &lt;/Elements&gt;
  &lt;ExtraData&gt;
    &lt;!-- Some XML is here --&gt;
  &lt;/ExtraData&gt;
&lt;/Root&gt;


If Elements is not the first element under Root the query need to be modified to add all elements before Elements first and all elements after Elements after.