How to copy namespace and attributes of root node with XSLT?
===

I'm new to XSL/XML and I need help with XSL transformation.

I have XML which starts like this

    <?xml version="1.0" encoding="UTF-8"?>
    <Invoice
      xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 ../ws/Invoice.xsd"
      xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
      xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
      xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2"
      xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
      xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2">
    <ext:UBLExtensions>
      <ext:UBLExtension>
        <cbc:ID>INVOICE1</cbc:ID>
	<cbc:Name>InvoiceIssuePlaceData</cbc:Name>
        <ext:ExtensionAgencyURI>urn:invoice:hr:issueplace</ext:ExtensionAgencyURI>
        <ext:ExtensionContent>
          <ext:InvoiceIssuePlace>London</ext:InvoiceIssuePlace>
        </ext:ExtensionContent>
      </ext:UBLExtension>
    </ext:UBLExtensions>
    <cbc:UBLVersionID>2.1</cbc:UBLVersionID>
    <cbc:ID>01 1206-2406-568</cbc:ID>

I want to create elements for all attributes, and to create element between <_> tags for the value of node which has attribute.

Here is the xsl...

    <?xml version='1.0' encoding='utf-8' ?>
    <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
      xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
      xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
      xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
      xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2"
      xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 ../ws/Invoice.xsd"
      version="1.0">
      <xsl:output method="xml"/>
       <xsl:template match="/">
         <xsl:apply-templates/>
       </xsl:template>
       <xsl:template match="@*|*|text()">
        <xsl:copy>
         <xsl:apply-templates select="@*|*|text()"/>
        </xsl:copy>
       </xsl:template>
       <xsl:template match="*[@*]">
        <xsl:element name="{name()}">
         <xsl:if test="count(@*)>=count(node())">
          <_>
           <xsl:value-of select="."/>
          </_>
         </xsl:if>
         <xsl:for-each select="@*">
          <xsl:element name="{name()}">
           <xsl:value-of select="."/>
          </xsl:element>
         </xsl:for-each>
         <xsl:if test="count(node())>count(@*)">
          <xsl:apply-templates select="*|text()"/>
         </xsl:if> 
        </xsl:element>
       </xsl:template>
    </xsl:stylesheet>

The problem is that this transformation doesn't transforms root node (Invoice) as I would need. I'm getting:

    <?xml version="1.0"?>
    <Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
      <xsi:schemaLocation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 ../ws/Invoice.xsd</xsi:schemaLocation>
No other attributes in Invoice and as new elements. Only xsi:schemaLocation, but with namespace defined on the level of that node.

What I'm doing wrong?

Thanks.