I can group it by ship method with
<xsl:template match="/DetailList">
<Batches>
<xsl:for-each-group select="details" group-by="shipMethod">
<Batch id="{current-grouping-key()}">
<xsl:apply-templates select="current-group()"/>
</Batch>
</xsl:for-each-group>
</Batches>
</xsl:template>