XSLT-go into first child then loop thru its children and output attribute names
<p>I'm new to XSLT. I'm trying to transform xml data to tab-delimited text file. I really appreciate your help in advance.</p>

<p>XML Data:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;xml_extract version="V1.2"&gt;
    &lt;tables&gt;
        &lt;table name="TAB_1"&gt;
            &lt;row&gt;
                &lt;columns&gt;
                    &lt;column name="ID" type="-5"&gt;1001410&lt;/column&gt;
                    &lt;column name="EXT_ID" type="-5"&gt;1001410&lt;/column&gt;
                    &lt;column name="LANG" type="12"&gt;en&lt;/column&gt;
                    &lt;column name="NAME" type="12"&gt;B10060601&lt;/column&gt;
                &lt;/columns&gt;
            &lt;/row&gt;
            &lt;row&gt;
                &lt;columns&gt;
                    &lt;column name="ID" type="-5"&gt;1001412&lt;/column&gt;
                    &lt;column name="EXT_ID" type="-5"&gt;1001412&lt;/column&gt;
                    &lt;column name="LANG" type="12"&gt;en&lt;/column&gt;
                    &lt;column name="NAME" type="12"&gt;B10141005&lt;/column&gt;
                &lt;/columns&gt;
            &lt;/row&gt;
            &lt;row&gt;
                &lt;columns&gt;
                    &lt;column name="ID" type="-5"&gt;1001414&lt;/column&gt;
                    &lt;column name="EXT_ID" type="-5"&gt;1001414&lt;/column&gt;
                    &lt;column name="LANG" type="12"&gt;en&lt;/column&gt;
                    &lt;column name="NAME" type="12"&gt;B10438001&lt;/column&gt;
                &lt;/columns&gt;
            &lt;/row&gt;
        &lt;/table&gt;
    &lt;/tables&gt;
&lt;/xml_extract&gt;
</code></pre>

<p>After XSLT transformation, I'd like below output in tab-delimited TEXT (not XML):</p>

<pre><code>ID  EXT_ID  LANG    NAME
1001410 1001410 en  B10060601
1001412 1001412 en  B10141005
1001414 1001414 en  B10438001
</code></pre>

<p>Thanks in advance,</p>

<p>The hard part is to output column headers. Besides hard code column headers, I tried below.</p>

<p>XSLT:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    &lt;xsl:output method="text"/&gt;
    &lt;xsl:template match="/"&gt;
        &lt;!-- Headers --&gt;
        &lt;xsl:for-each select="//columns[1]/column"&gt;
            &lt;xsl:value-of select="@name"/&gt;
            &lt;xsl:text&gt;&amp;#x9;&lt;/xsl:text&gt; &lt;!-- tab delimited --&gt;
        &lt;/xsl:for-each&gt;
        &lt;xsl:text&gt;&amp;#x0A;&lt;/xsl:text&gt; &lt;!-- new line --&gt;
        &lt;!-- Data --&gt;
        &lt;xsl:for-each select="//columns/column"&gt;
            &lt;xsl:value-of select="."/&gt;
            &lt;xsl:choose&gt;
                &lt;xsl:when test="not(@name='NAME')"&gt;
                    &lt;xsl:text&gt;&amp;#x9;&lt;/xsl:text&gt; &lt;!-- tab delimited --&gt;
                &lt;/xsl:when&gt;
                &lt;xsl:when test="@name='NAME'"&gt;
                    &lt;xsl:text&gt;&amp;#x0A;&lt;/xsl:text&gt; &lt;!-- new line --&gt;
                &lt;/xsl:when&gt;
            &lt;/xsl:choose&gt;
        &lt;/xsl:for-each&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</code></pre>

<p>Result:</p>

<pre><code>ID  EXT_ID  LANG    NAME    ID  EXT_ID  LANG    NAME    ID  EXT_ID  LANG    NAME    
1001410 1001410 en  B10060601
1001412 1001412 en  B10141005
1001414 1001414 en  B10438001
</code></pre>