recursive structures and output

Subject: recursive structures and output
From: "Gill, Fray" <fray.gill@xxxxxxxx>
Date: Wed, 30 Jun 2004 13:13:20 +0100
David, 

Hope you can help.

I have been trying to work this example and had little luck.

In recursive structure like this (where A and F repeat)

<A1>
	<b1></b1>
	<c1></c1>
	<D1>
		<F1>
			<g1></g1>
		</F1>
		<F2>
			<g2></g2>
		</F2>
		<F3>
			<g3></g3>
		</F3>		
	</D1>
</A1>
<A2>
	<b2></b2>
	<c2></c2>
	<D2>
		<F4>
			<g1></g1>
		</F4>
		<F5>
			<g2></g2>
		</F5>
		<F6>
			<g3></g3>
		</F6>		
	</D2>
</A2>

I am translating this xml file from this format to the following (where for
each F, I generate a new node set starting from A.)

<A1>
	<b></b>
	<c></c>
	<D>
		<F>
			<g1></g1>
		</F>
	</D>
</A1>
<A1>
	<b1></b1>
	<c1></c1>
	<D1>
		<F2>
			<g2></g2>
		</F2>
	</D1>
</A1>
<A1>
	<b1></b1>
	<c1></c1>
	<D1>
		<F3>
			<g3></g3>
		</F3>
	</D1>
</A1>
<A2>
	<b2></b2>
	<c2></c2>
	<D2>
		<F4>
			<g1></g1>
		</F4>
	</D2>
</A2>
<A2>
	<b2></b2>
	<c2></c2>
	<D2>
		<F5>
			<g2></g2>
		</F5>
	</D2>
</A2>


The problem comes when I am trying to add another 2 tag into the output,

One stating: the "count" value of the <F> element (in total 6 <F> elements
exist.).  Tag name = <subref>
and secondly stating: that for every A that I loop through I want to add an
element after the last <F> element. Tag name <pORc>

therefore my code looks something like this, which works.

<xsl:for-each select="A/D/F">
	<A>
		<xsl:call-template name="count_number_of_F_elements"/>
	</A>
</xsl:for-each>
...
<xsl:template name="count_number_of_F_elements">

<b><xsl:value-of select="../../b"/><b>
<c><xsl:value-of select="../../c"/><c>
<D>
	<F>
		<g><xsl:value-of select="g"/><c>
	</F>
	<subref>
		<xsl:value-of select ="position()"/>
	</subref>
</D>
</xsl:template>

What I am not able to do is add the <pORc> element.  For every <F> it should
be <pORc>C<pORc>, but for the last one in any given <A> it needs to be <P>

Does this make sense:

hope you can help.

Fray










<xsl:call-template name="count_number_of_F_elements"/>

==============================================================================
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==============================================================================


Current Thread