Subject: [xsl] Newbie : conditional node move From: Godefroid Chapelle <gotcha@xxxxxxxx> Date: Wed, 16 May 2001 10:15:37 +0200 |
Hi all, A question about a problem I tried to solve the whole yesterday evening... I could not find enough information or apply it correctly even in Michael Kay's book. I have the following two cases: 1) input <AAA> <BBB>bbb</BBB> <CCC>ccc</CCC> <DDD>ddd</DDD> <EEE>eee</EEE> </AAA> wished output <AAA> <DDD> <XXX>bbb</XXX> ddd</DDD> <EEE>eee</EEE> </AAA> 2) input <AAA> <BBB>zzz</BBB> <CCC>ccc</CCC> <DDD>ddd</DDD> <EEE>eee</EEE> </AAA> output <AAA> <DDD>ddd</DDD> <EEE>eee</EEE> </AAA> In words : There are nodes I want to delete (ie CCC) : I can do that There are nodes I want to copy (ie EEE) : I can do that also. There is a node I want to copy (ie DDD) and modify conditionnally depending on another node's value (ie BBB): THIS IS WHAT I WAS NOT ABLE TO DO. I tried the following stylesheet: <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <!-- copy all--> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <!-- delete CCC--> <xsl:template match="inutilise"> </xsl:template> <!-- copy DDD and modify depending on BBB--> <xsl:template match="DDD"> <xsl:if test="/BBB='bbb'"> <XXX><xsl:value-of select="/BBB"/></XXX> </xsl:if> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> I hope this is something someone can help me with or give me a pointer to a good reference somewhere... Thanks -- Godefroid Chapelle BubbleNet sprl rue Victor Horta, 30 1348 Louvain-la-Neuve Belgium Tel 010 457490 Mob 0477 363942 TVA 467 093 008 RC Niv 49849 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem of syntax of filt, Stephane . Le-Deaut | Thread | RE: [xsl] Newbie : conditional node, Jarno Elovirta |
[xsl] Problem of syntax of filter ?, Stephane . Le-Deaut | Date | Re: [xsl] Problem of syntax of filt, Ingo Schildmann |
Month |