Использование:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="MyAuditList">
<Audit>
<xsl:copy-of select="Audit[1]/*"/>
<xsl:apply-templates select="Audit[2]"/>
</Audit>
</xsl:template>
<xsl:template match="Audit">
<previousAudit>
<xsl:copy-of select="*"/>
<xsl:apply-templates select="following-sibling::Audit"/>
</previousAudit>
</xsl:template>
</xsl:stylesheet>
Выход:
<Audit>
<time>12:35</time>
<number>13354</number>
<previousAudit>
<time>1:27</time>
<number>13650</number>
<previousAudit>
<time>7:05</time>
<number>10659</number>
</previousAudit>
</previousAudit>
</Audit>
Если вам нужно вывести пустое previousAudit
, используйте это:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="MyAuditList">
<Audit>
<xsl:copy-of select="Audit[1]/*"/>
<previousAudit>
<xsl:apply-templates select="Audit[2]"/>
</previousAudit>
</Audit>
</xsl:template>
<xsl:template match="Audit">
<xsl:copy-of select="*"/>
<previousAudit>
<xsl:apply-templates select="following-sibling::Audit"/>
</previousAudit>
</xsl:template>
</xsl:stylesheet>
Выход:
<Audit>
<time>12:35</time>
<number>13354</number>
<previousAudit>
<time>1:27</time>
<number>13650</number>
<previousAudit>
<time>7:05</time>
<number>10659</number>
<previousAudit />
</previousAudit>
</previousAudit>
</Audit>