[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: recursive structures and output

Subject: RE: recursive structures and output
From: "Gill, Fray" <fray.gill@xxxxxxxx>
Date: Wed, 30 Jun 2004 14:09:38 +0100
xml recursive structure
Deal all,


> 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
> 
> 
> 
> 
> 
> 
> 
> 

==============================================================================
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.