It's also a problem with other parsers (MSXML, .NET System.XML).
Try to re-arrange the order in the XSL. You have to be explicit in where you want your element.
Here's a sample XML / XSL
<xml>
<e>One</e>
<e>Two</e>
<e>Three</e>
</xml>
You can add both elements and attributes with the following XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xml>
<xsl:for-each select='/xml/e'>
<xsl:element name='e'>
<xsl:attribute name='newatt'>New attribute</xsl:attribute>
<xsl:value-of select='.'/>
</xsl:element>
<xsl:element name='newlement'>
<xsl:attribute name='newatt'>New attribute in new element</xsl:attribute>
new element value
</xsl:element>
</xsl:for-each>
</xml>
</xsl:template>
</xsl:stylesheet>
Creates this
<?xml version="1.0"?>
<xml>
<e newatt="New attribute">One</e>
<newlement newatt="New attribute in new element">
new element value
</newlement>
<e newatt="New attribute">Two</e>
<newlement newatt="New attribute in new element">
new element value
</newlement>
<e newatt="New attribute">Three</e>
<newlement newatt="New attribute in new element">
new element value
</newlement>
</xml>