Subject: Re: [xsl] Rename element From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx> Date: Mon, 7 Nov 2005 10:36:16 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Rename element, Shailesh Shinde | Thread | RE: [xsl] Rename element, Shailesh Shinde |
[xsl] Recursion, Shailesh Shinde | Date | RE: [xsl] Rename element, Shailesh Shinde |
Month |