xsl-list
[Top] [All Lists]

RE: Rename element

2005-11-07 02:41:42
Thanks a lot this helps me out!

-----Original Message-----
From: Ragulf Pickaxe [mailto:ragulf(_dot_)pickaxe(_at_)gmail(_dot_)com] 
Sent: Monday, November 07, 2005 3:06 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] 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 :-)

--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>