[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Rename element

Subject: Re: Rename element
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Mon, 7 Nov 2005 10:36:16 +0100
xslt rename element
Hi Shailesh,

You must know that XSLT is input driven. The output depends on the
input. You have some ways of directing the flow, though. Let us take a
look on the flow of your transformation:

<xsl:template match="/">
This template matches the absolute root of the document. That is, you
are now above your root element (sample ). You create a test element
and calls:

<xsl:apply-templates/>
This applies templates on all child elements of the current. As you
are in the root, the only element below is the one named sample. Now
the compiler searches the XSLT document for all templates that can
match sample and chooses the one that matches best. That will be this
template:

<xsl:template match="*[not(self::script)]">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>
This template makes a copy of the current element (sample) and applies
templates to its children (sample1) which does exactly the same.

Only when you encounter script elements is a different template
invoked. This one changes it to scripting (which is what you want).
And copies the attributes of script to the new element. It does not
apply any templates to it's children, so if at a later time you add
children to script elements, these will not be invoked.

In your problem, what you need to do, is to steer your XSLT to start
at the topmost element that you want to process, namely you sample1
element.

<xsl:template match="/">
  <test>
    <xsl:apply-templates select="sample/sample1"/>
  </test>
</xsl:template>

I hope this helps.
Ragulf Pickaxe :-)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.