The following style sheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="varList[following-sibling::*[1][self::simpleSteps]]" />
<xsl:template match="simpleSteps">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:copy-of select="preceding-sibling::varList[1]" />
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
On this input:
<executionPlan name="Test">
<paramList>
<param name="param1" default="" />
</paramList>
<varList>
<var name="bla" default=":[param1]" />
</varList>
<varList>
<var name="bla2" default=":[param2]" />
</varList>
<simpleSteps limitToHostSet="bla">
<execNative>
<exec cmd="/bin/sh" />
</execNative>
</simpleSteps>
</executionPlan>
Produces:
<executionPlan name="Test">
<paramList>
<param name="param1" default="" />
</paramList>
<varList>
<var name="bla" default=":[param1]" />
</varList>
<simpleSteps limitToHostSet="bla">
<varList>
<var name="bla2" default=":[param2]" />
</varList>
<execNative>
<exec cmd="/bin/sh" />
</execNative>
</simpleSteps>
</executionPlan>
Edit: Only the immediately preceding varList is moved into its associated simpleSteps. All other varList elements are copied through unchanged.
It's suddenly not clear to me whether this is the desired behavior, or if there may be multiple varList elements already inside the simpleSteps element that should be unchanged. See my original solution for that case:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="varList" />
<xsl:template match="simpleSteps">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:copy-of select="../varList" />
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
On this input:
<executionPlan name="Test">
<paramList>
<param name="param1" default="" />
</paramList>
<varList>
<var name="bla" default=":[param1]" />
</varList>
<simpleSteps limitToHostSet="bla">
<varList>
<var name="bla7" default=":[param7]" />
</varList>
<execNative>
<exec cmd="/bin/sh" />
</execNative>
</simpleSteps>
</executionPlan>
Produces:
<executionPlan name="Test">
<paramList>
<param name="param1" default="" />
</paramList>
<simpleSteps limitToHostSet="bla">
<varList>
<var name="bla" default=":[param1]" />
</varList>
<varList>
<var name="bla7" default=":[param7]" />
</varList>
<execNative>
<exec cmd="/bin/sh" />
</execNative>
</simpleSteps>
</executionPlan>
varListinside the firstsimpleSteps?simpleSteps'varListchild should be merge or left as sibling?