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

Recursive calls to a named template

Subject: Recursive calls to a named template
From: Ram <sram_30@xxxxxxxxx>
Date: Thu, 20 Nov 2003 05:28:10 -0800 (PST)
recursive named template
Hi,
 Can anyone please give me hint how to copy the previous operations?
 Actually, the input xml file is a dynamic one and the number of 'group'
is arbitrary. The xml source would look like this:

<formatted-xml>
  <group><identifier>a</identifier>
    <signature>signature <identifier>DNSQuery1</identifier>
      <in>in<long>long</long><identifier>ant</identifier></in>
    </signature>
  </group>
  <group><identifier>b</identifier><identifier>a</identifier>
    <signature>signature<identifier>DNSQuery2</identifier>        
       <inout>inout<string>string</string><identifier>grass</identifier>
       </inout>
    </signature>
  </group>
  <group><identifier>c</identifier><identifier>b</identifier>
     <signature>signature<identifier>DNSQuery3</identifier>               
        <out>out<boolean>boolean</boolean>        
                          <identifier>fish</identifier></out>
     </signature>
  </group>
</formatted-xml>

    What I have to do is, I should copy the signature part the first group
identifier 'a' to the signature part in group identifier 'b', because it
is followed by the group identifier 'a'.
    Similarly, the third group identifier 'c' is followed by the second
group identifier 'b' (which should have already copied the 
first group identifier a's signature part) and so the second group
identifier's signature part should be copied to the third group identifier
signature part.

I tried the following xsl.

<xsl:template match="group">
	<xsl:variable name="groupID" select="identifier"/>
	group<xsl:text> </xsl:text><xsl:value-of  
                 select="$groupID"/>Interface {
	<xsl:call-template name="generation"/>	
	<xsl:apply-templates select="generation"/>
	<xsl:apply-templates select="group"/>
	}
</xsl:template>
<xsl:template name="generation" match="signature">
   <!--How the signature part output should look like goes here-->
   <!--Copying the previous group identifier signature part-->
   <xsl:if test="identifier[2]= preceding::group/identifier">
     <xsl:copy>
         <xsl:apply-templates select="preceding::group/signature"/>
      </xsl:copy>
   </xsl:if>
</xsl:template>
 
  Charles Knell suggested that the problem could be resolved by recursive
calls to a named template. As the number of 'group's is arbitrary,I don't
know exactly how to fix this.
 Can anyone show me the right direction?

Thanks and regards,
Ram

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.