How to invert XML data tags via XSLT?

advertisements

For example, below XML file.

<person>
<name>Adam</name>
<lname>Palmer</lname>
<profession> Programmer</profession>
<salary>80,000</salary>
</person>

Now, In XSLT, IF I code,

<xsl:template match="person">
 <xsl:apply-templates/><xsl:text> </xsl:text>
</xsl:template>

So, In HTML file It will display: Adam Palmer Programmer 80,000.

But I need following output: Palmer Adam Programmer 80,000.

I need to reverse order of first 2 data tags.

Any idea folks ?


Push style stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:strip-space elements="*"/>
    <xsl:template match="person/*">
        <xsl:apply-templates/>
        <xsl:text> </xsl:text>
    </xsl:template>
    <xsl:template match="person">
        <xsl:apply-templates select="lname"/>
        <xsl:apply-templates select="name"/>
        <xsl:apply-templates select="*[not(self::name|self::lname)]"/>
        <xsl:text>
</xsl:text>
    </xsl:template>
</xsl:stylesheet>

Output:

Palmer Adam  Programmer 80,000