xsl-list
[Top] [All Lists]

Re: [xsl] Creating elements in an arbitrary position in the result document

2010-01-17 21:06:42
<xsl:template match="A">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <new_element attrC="value1" attrD="value2"/>
      <xsl:apply-templates select="node()"/>
    </xsl:copy>
</xsl:template>

better?

<xsl:template match="A">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <new_element>
        <xsl:copy-of select=".//B/C/@*" />
        <xsl:copy-of select=".//B/C/D/@*" />
        <xsl:apply-templates />
      </new_element>
    </xsl:copy>
</xsl:template>

<xsl:template match="@*|node()"><!--identity for all other nodes except B-->
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="B">
  <xsl:copy>
    <xsl:apply-templates select="@*|node() except (C union D)"/>
  </xsl:copy>
</xsl:template>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--