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 16:15:41 +0100
Hi David

  This is the complete XML. It appears that the output that I am getting is
from this part of the code:

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

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

  I Have tried running it with and without the following part of the code and
appears to make no difference to the output.

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

  So where is it going wrong? it looks like the above code is having no impact
on the output results.

Here is the full xml.

<response>
- <getClientDetails_Res xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="getClientDetails_Res.xsd">
- <header>
  <mc>000021</mc>
- <source>
  <systemInstance>33</systemInstance>
  <subSystemInstance>1</subSystemInstance>
  <requestUniqueID>0</requestUniqueID>
  <responseUniqueID>0</responseUniqueID>
  </source>
  <sessionID>0</sessionID>
  </header>
- <error>
  <success>true</success>
  </error>
- <request>
  <clientID>10675474</clientID>
  </request>
- <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>
  </getClientDetails_Res>
  </response>


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




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

> What I am getting at the moment is the following:-
your posted xml didn't have response as a grandchild of response so I'll
have to guess that's OK, * selects client and then


   		   <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:apply-templates mode="table" select="*"/>
		  </xsl:template>


should put all the data in a table, but i expect that the output you are
seeing is from the default template (ie, it's the same as as the output
from a stylesheet that has no templates). Without seeing what your
input looks like I can't suggest whet match pattern should be on your
initial template.
If the xml posted is the complete xml document, then you want something
like
<xsl:template match="/response"
<table>
    		    <xsl:apply-templates select="*" mode="table"/>
</table>
</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