[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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.

Hi,


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="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />


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

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

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

</xsl:stylesheet>


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 (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) "Et ipsa scientia potestas est" - Francis Bacon , Meditationes sacrae


Current Thread
Keywords