xsl-list
[Top] [All Lists]

[xsl] Passing xml nodes to a function

2006-08-09 07:49:22
Hi,
 
    I have a requirement to pass a parent node to a recursive function and then 
to recurse through all the child nodes. I am a novice at xsl and so this is 
proving to be quite taxing.

 Here is the code:

   This is where I call the function:-
   <table>
                
                <xsl:call-template name="getChildDetails">
                        
                    <xsl:with-param name="children" 
select=".//response/*/response/*"/>
                </xsl:call-template>    
 </table> 


 and this is the actual function where I want to test for the presence of 
children, output the node name and then call the method again until all nodes 
are printed
:-


<xsl:template name="getChildDetails">
        <xsl:param name="children"/>
    
        <xsl:if test="count(children::*) > 0">
                                                 
          <tr>                                   
             <td><span class="text"><xsl:value-of select="name()"/></span></td> 
 
          </tr>                                   
             <xsl:call-template name="getChildDetails">
                 <xsl:with-param name="children" select="child::*"/>
             </xsl:call-template>
        </xsl:if>

</xsl:template>

  Here is an example of an XML:


  <teleNumbers>
  <telList>
    <numbers>
      <teleType>H</teleType>
      <teleNumber>0145454545</teleNumber>
    </numbers> 
  </telList> 
</teleNumbers>

   The output I expect from this xsl once it has run through the recursive 
function is as follows:-

          teleNumbers 
              telList
                  numbers
                teleType        H
                teleNumber      0145454545

  I look forward to your help.

Rabinder.


   


INTERNATIONAL FINANCIAL DATA SERVICES (UK) LTD Tel: +44 1268 44 3000
********************** N O T I C E *********************************

This message and any attachments is intended only for the individual or company 
to which it is addressed and may contain
information which is privileged, confidential or prohibited from disclosure or 
unauthorised use. If the recipient of this
transmission is not the intended recipient, or the employee or agent 
responsible for delivering such materials to the
intended recipient, you are hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, 
modification, distribution and/or publication of this e-mail message or its 
attachments other than by it's intended
recipient is strictly prohibited by the sender. If you have received it in 
error, please notify us immediately by 
telephone on the number above and destroy the message and all copies in your 
possession.

International Financial Data Services (UK) Ltd is authorised and regulated by 
the Financial Services Authority.

This footnote also confirms that this email message has been swept by 
MIMEsweeper for the presence of computer viruses.

**********************************************************************


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>