This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Move elements to an upper level
- To: "Borca, Olivier" <Olivier dot Borca at softplumbers dot com>
- Subject: Re: [xsl] Move elements to an upper level
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Tue, 13 Mar 2001 13:24:17 +0000
- CC: "Xsl-List (E-mail)" <XSL-List at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <7FDE48022CEFA544878EA148687723DF0E1514@mqgenevaex01.myqube.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Olivier,
> In fact, I want to keep the TrafficType element which becomes empty,
> and move all the its TrafficTypeValueMap elements at the same level
> as TrafficType.
> Is it possible to do that ?
Sure. Within a template for the parent of the TrafficType element
(i.e. the CIM_ActiveConnection element), first apply templates to the
TrafficType element, and then to the TrafficType element's child
TrafficTypeValueMap elements:
<xsl:template match="CIM_ActiveConnection">
<xsl:apply-templates select="TrafficType" />
<xsl:apply-templates select="TrafficType/TrafficTypeValueMap" />
</xsl:template>
Now, within the template for the TrafficType element, you want to copy
the element itself and its attributes, but leave the content empty:
<xsl:template match="TrafficType">
<xsl:copy>
<xsl:copy-of select="@*" />
</xsl:copy>
</xsl:template>
Within the TrafficTypeValueMap template, you want to make a complete
copy of the element:
<xsl:template match="TrafficTypeValueMap">
<xsl:copy-of select="." />
</xsl:template>
The secret is in applying templates to the nodes that you want to
process, and in having templates for those nodes do what you want them
to do.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list