Re: [xsl] is recursion the best way to solve this?

Subject: Re: [xsl] is recursion the best way to solve this?
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Tue, 01 Mar 2005 21:05:05 +0100
Tempore 20:44:51, die 03/01/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit anil jacob <anujcb@xxxxxxxxx>:

I have been trying to write an xsl transfor for
converting the following src xml to dest xml. No
success yet, wondering if anyone of you have faced
similar problem, appreciate if you could share any
ideas. The problem is how to wrap the OuterTag over
the InnerTag and the OuterTag can be nested.


Playing around with 'xsl:apply-templates' and 'xsl:copy' can do the trick (there are plenty of other ways too)

<xsl:stylesheet version="1.0" xmlns:xsl="";>
<xsl:output indent="yes" />

<xsl:template match="/Object">
		<xsl:apply-templates select="*[1]"/>

<xsl:template match="/Object/*">
	<xsl:apply-templates select="following-sibling::Object/*[1]"/>

<xsl:template match="*">
		<xsl:apply-templates select="following-sibling::Object/*[1]"/>


But I do wonder why the wanted output is not like this: <Root> <HeaderTag> <OuterTag> <InnerTag/> </OuterTag> <InnerTag/> <OuterTag> <OuterTag> <InnerTag/> </OuterTag> <InnerTag/> </OuterTag> </HeaderTag> </Root>

regards, -- Joris Gillis ( "Et ipsa scientia potestas est" - Francis Bacon , Meditationes sacrae

Current Thread