RE: [xsl] Passing xml nodes to a function

Subject: RE: [xsl] Passing xml nodes to a function
From: "Bansal, Rabinder" <RBansal@xxxxxxxxxxxxxxx>
Date: Thu, 10 Aug 2006 15:17:30 +0100
Hi David
     Thanks for your suggestion. It seems to extract the data okay but the
output is not correct. What I am getting at the moment is the following:-

Joe Mrs JEANETTE CHANDLER 1960-01-01 JH876329H M S 000001 test@xxxxxxxxx H
02392477011

    As you can see it does not get the node name or split the text into
different table data cells. Your code that you send me looks fine, so where is
it going wrong?


     		<table style="position:relative; left:30px;">

    		    <xsl:apply-templates select=".//response/*/response/*"
mode="table"/>
 		</table>

   		   <xsl:template match="*" mode="table">
		     <tr>
		       <td><xsl:value-of select="name()"/></td>
		       <xsl:if test="not(*)"><td><xsl:value-of select="."/></td></xsl:if>
		     </tr>
		  </xsl:template>


This is the xml:
<response>
    <client>
	<welcomeName>Joe </welcomeName>
	<title>Mrs</title>
	<name>
		<firstName>JEANETTE</firstName>
		<surname>CHANDLER</surname>
	</name>
	<DOB>1960-01-01</DOB>
	<NINO>JH876329H</NINO>
	<gender>M</gender>
	<maritalStatus>S</maritalStatus>
	<clientType>000001</clientType>
	<email>test@xxxxxxxxx </email>
	<teleNumbers>
		<telList>
			<numbers>
				<teleType>H</teleType>
				<teleNumber>02392477011</teleNumber>
			</numbers>
		</telList>
	</teleNumbers>
    </client>
</response>

Look forward to the solution.
Rabinder.





-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: 09 August 2006 16:19
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Passing xml nodes to a function



I suspect that ypu don't want to use call-template and named templates
at all here, and just use apply-templates which would simplify your code
greatly.

It's not clear what output you want, you suggested code allways makes
table rows tr containing a single td but you showed an indented output

          teleNumbers
              telList
                  numbers
		teleType	H
		teleNumber	0145454545


what html do you intend here?


It's not clear how your initial selection .//response/*/response/*" fits
with your input document (the sample you showed didn't have a response
element but I'm assuming that what you showed was teh content of a
typical <response> ?


call-template does not change the current node so  as you recurse along
your $children the current node always stays teh same so
<xsl:value-of select="name()"/> will produce the same text  at each
stage,

I think you want something like
   <table>
    <xsl:apply-templates" select=".//response/*/response/*" mode="table"/>
 </table>

<xsl:template match="*" mode="table">
<tr>
<td><xsl:value-of select="name()"/></td>
<xsl:if test="not(*)"><td><xsl:value-of select="."/></td></xsl:if>
</tr>
</xsl:template>

David



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.

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

Current Thread