When I call this template I get the following results.
155IT Matches 155OO
155OO Matches 155OO
155PP
The XML I am processing does have three rows and those are the values, but why is the test returning true for the first two and false for the last one? How should I be doing the string comparison?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template name="ProofOfConcept">
<xsl:param name="Lines"/>
<xsl:param name="MainDeliveryCode"/>
<xsl:choose>
<xsl:when test="$Lines">
<xsl:variable name="CurrentDeliveryCode" select="$Lines/DLVYLOCCD"/>
<p>
<xsl:choose>
<xsl:when test=" $MainDeliveryCode = $CurrentDeliveryCode">
<xsl:value-of select="$CurrentDeliveryCode"/> Matches <xsl:value-of select="$MainDeliveryCode"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Lines"/> Fails <xsl:value-of select="$MainDeliveryCode"/>
</xsl:otherwise>
</xsl:choose>
</p>
<xsl:call-template name="ProofOfConcept">
<xsl:with-param name="Lines" select="$Lines[position() > 1]"/>
<xsl:with-param name="MainDeliveryCode" select="$MainDeliveryCode"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title></title>
</head>
<body>
<xsl:call-template name="ProofOfConcept">
<xsl:with-param name="Lines" select="data/Lines/LINE"/>
<xsl:with-param name="MainDeliveryCode" select="data/header/DLVYLOCCD"/>
</xsl:call-template>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Sample data
<?xml version="1.0"
encoding="ISO-8859-1"
standalone="yes"?> <data>
<header><DLVYLOCCD>155OO</DLVYLOCCD>
</header> <Lines>
<LINE><DLVYLOCCD>155IT</DLVYLOCCD></LINE>
<LINE><DLVYLOCCD>155OO</DLVYLOCCD></LINE>
<LINE><DLVYLOCCD>155PP</DLVYLOCCD></LINE>
</Lines> </data>
Thanks for any advice.