[thelist] XML: If statement in stylesheet. (fwd)

Daniel J. Cody djc at members.evolt.org
Thu May 3 10:04:53 CDT 2001


---------- Forwarded message ----------
Date: Thu, 3 May 2001 11:40:39 +0100 
From: Tarrant Costelloe <tcostelloe at insur-e.net>
To: "'thelist at evolt.org'" <thelist at evolt.org>
Subject: XML: If statement in stylesheet.

Unfortunately you cannot view the project due to network restraints, but
here is the problem:

I have a policysummary.asp file which lookups a client database using two
bits of code:

1) First time, pulling back the policy summary:

<%
  sXMLPolicy = UWRetrievePolicy(Request("hdnID"))
  Response.write createHTML (sXMLPolicy,"PolicySummary.xsl")
%>

2) Second time, checking for duplicate claims/policies:

<%
  sXMLClaims =
CNDuplicateClaimSearch(session("Policy"),Session("IncidentDate"))
  Response.write createHTML (sXMLClaims,"DuplicateClaims.xsl")
%>

Now the problem is, is that I seem un-able to write an 'if statement' within
the xsl stylesheet to only show the duplicateclaims section if their is in
fact a duplicate claim. Currently if their isn't, it will still show the top
of the duplicateclaims table, see below:

<tr>Duplicate Claim Found</tr><tr bgcolor="#999999" height="1" border="0"
cellspacing="1" cellpadding="0"><td>ID</td><td>Number</td><td>Policy
Number</td><td>Surname</td><td>Incident
Date</td><td>Property</td><td>Insurance Type</td><td>Select</td></tr>

And if their is, it obviously shows the above and rest of the stylesheet:

<xsl:template match="Claim">
<td bgcolor="#CCCCCC"><xsl:value-of select="ID"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="Number"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="PolicyNumber"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="Surname"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="IncidentDate"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="PropertyTag"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="InsuranceType"/></td>
<td bgcolor="#CCCCCC"><input type="submit" value="OK"><xsl:attribute
name="onClick"> hdnID.value=<xsl:value-of
select="ID"/></xsl:attribute></input></td>
</xsl:template>


Sorry for the long e-mail but if anyone thinks they know of a suitable 'if
statement' to be placed in the stylesheet and solve the problem then I am
most grateful. I have included the stylesheet below as am unsure of Evolt's
policy on attachments:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<table width="0" border="0" cellspacing="1" cellpadding="10" align="center">
<tr>Duplicate Claim Found</tr><tr bgcolor="#999999" height="1" border="0"
cellspacing="1" cellpadding="0"><td>ID</td><td>Number</td><td>Policy
Number</td><td>Surname</td><td>Incident
Date</td><td>Property</td><td>Insurance Type</td><td>Select</td></tr>
<xsl:for-each select="//Claim">
<xsl:if test="file_date[not(. = @previous_date)]"> do something </xsl:if> 

	<tr>
		<xsl:apply-templates select="."/>
	</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="Claim">
<td bgcolor="#CCCCCC"><xsl:value-of select="ID"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="Number"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="PolicyNumber"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="Surname"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="IncidentDate"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="PropertyTag"/></td>
<td bgcolor="#CCCCCC"><xsl:value-of select="InsuranceType"/></td>
<td bgcolor="#CCCCCC"><input type="submit" value="OK"><xsl:attribute
name="onClick"> hdnID.value=<xsl:value-of
select="ID"/></xsl:attribute></input></td>
</xsl:template>

</xsl:stylesheet>


> Tarrant Costelloe
> Web Developer
> InsurE-com Ltd.
> ------------------------------------
> Tel:	+44 (0)1273 852014
> tcostelloe at insur-e.net
http://www.insur-e.net





More information about the thelist mailing list