For some reason, I am getting duplicate entries when I access an external SQL table. Even when I select from the SQL table using the primary ID
number, I get duplicates. This doesn’t happen everywhere, all the time, but I
can’t figure out how to limit to only one entry (since there IS
only entry – there is only one person in the web_AthleticsRoster table with the
ID number of 292!)
Here is my query (XSLT):
<xsl:variablename="athProfile"select="SQL:GetDataSet('DBname',
'SELECT ath_Id, ath_FirstName, ath_LastName, ath_TeamId, ath_Position, ath_Birthdate,
ath_JerseyNumber, ath_ProfileImage, ath_Biography, ath_Hometown, ath_Awards,
ath_Studies, ath_YearsPlayed, team_Id, team_Name FROM web_AthleticsRoster INNER
JOIN web_AthleticsTeams ON
web_AthleticsRoster.ath_TeamId=web_AthleticsTeams.team_Id WHERE ath_Id = 292',
'athProfile')"/>
As you can see, I've limited my request to where the primary id equals 292. But I am getting two records, which are actually the same one. Any ideas why this might be happening?
I'll second Lee's observation here - you're most likely doing something in the XSLT which cause it to render twice, so let's see the XSLT that actually generates the content from the SQL result.
Thanks for the replies. Here is the XSLT that goes with the SQL call: (I'm using a lot of <xsl:choose> stuff because not all athletics profiles have all the info filled in, and I don't want headings to show up if there isn't any info to display; makes for long code...)
Sure looks like we should investigate the results from the SQL call - try Lee's copy-of snippet and see if you're not actually getting duplicate records in the XML.
Otherwise your'e having a problem somewhere else.
/Chriztian
PS: Remind me to show you how to get rid of all that choose stuff! :-)
Getting duplicate SQL records
For some reason, I am getting duplicate entries when I access an external SQL table. Even when I select from the SQL table using the primary ID number, I get duplicates. This doesn’t happen everywhere, all the time, but I can’t figure out how to limit to only one entry (since there IS only entry – there is only one person in the web_AthleticsRoster table with the ID number of 292!)
Here is my query (XSLT):
As you can see, I've limited my request to where the primary id equals 292. But I am getting two records, which are actually the same one. Any ideas why this might be happening?
Hi Luke,
This raises 2 questions.
1. What happens when you run the SQL query against the database directly? (Guessing that there should be only 1 record?)
2. What are you doing with the "$athProfile" variable in the XSLT after it has been assigned? (e.g. looping, etc)
Have you tried doing an <xsl:copy-of> of the variable?
(Note I only use the <xmp> tags for debugging - it's an old old HTML3 trick)
Cheers, Lee.
I'll second Lee's observation here - you're most likely doing something in the XSLT which cause it to render twice, so let's see the XSLT that actually generates the content from the SQL result.
/Chriztian
Thanks for the replies. Here is the XSLT that goes with the SQL call: (I'm using a lot of <xsl:choose> stuff because not all athletics profiles have all the info filled in, and I don't want headings to show up if there isn't any info to display; makes for long code...)
<xsl:template match="/">
<xsl:for-each select = "$athProfile//athProfile">
<xsl:sort select="ath_LastName" order="ascending" />
<xsl:if test="position() >= $startRecord and position() <= $endRecord">
<div class = "profile">
<xsl:choose>
<xsl:when test="ath_ProfileImage != ''">
<span class = "profilephoto">
<img>
<xsl:attribute name = "src">http://images.briercrest.ca/images/photos/profiles/athletics/<xsl:value-of disable-output-escaping="yes" select = "ath_ProfileImage" /></xsl:attribute>
<xsl:attribute name = "alt"><xsl:value-of select="ath_FirstName"/> <xsl:value-of select="ath_LastName"/></xsl:attribute>
</img>
</span>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<h1 class = "name">
<xsl:value-of disable-output-escaping="yes" select = "ath_FirstName" /> <xsl:value-of disable-output-escaping="yes" select = "ath_LastName" />
</h1>
<table>
<xsl:choose>
<xsl:when test="ath_Position != ''">
<tr><td>Position:</td>
<td><xsl:value-of disable-output-escaping="yes" select = "ath_Position" /></td></tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="ath_JerseyNumber != ''">
<tr>
<td>Number:</td>
<td><xsl:value-of disable-output-escaping="yes" select = "ath_JerseyNumber" /></td>
</tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="team_Name != ''">
<tr><td>Team:</td>
<td><xsl:value-of disable-output-escaping="yes" select = "team_Name" /></td></tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="ath_Hometown != ''">
<tr><td>Hometown:</td>
<td><xsl:value-of disable-output-escaping="yes" select = "ath_Hometown" /></td></tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="ath_Birthdate != ''">
<tr><td>Birthdate:</td>
<td><xsl:value-of disable-output-escaping="yes" select = "ath_Birthdate" /></td></tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="ath_YearsPlayed != ''">
<tr><td>Years played:</td>
<td><xsl:value-of disable-output-escaping="yes" select = "ath_YearsPlayed" /></td></tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="ath_Studies != ''">
<tr><td>Program:</td>
<td><xsl:value-of disable-output-escaping="yes" select = "ath_Studies" /></td></tr>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</table>
<xsl:choose>
<xsl:when test="ath_Biography != ''">
<h2>Biography</h2>
<xsl:value-of disable-output-escaping="yes" select = "ath_Biography" />
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="ath_Awards != ''">
<h2>Awards</h2>
<xsl:value-of disable-output-escaping="yes" select = "ath_Awards" />
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</div><!-- profile -->
<div style = "clear: both;"></div>
</xsl:if>
</xsl:for-each>
</xsl:template>
Thanks for helping me out!
Hi Luke,
Sure looks like we should investigate the results from the SQL call - try Lee's copy-of snippet and see if you're not actually getting duplicate records in the XML.
Otherwise your'e having a problem somewhere else.
/Chriztian
PS: Remind me to show you how to get rid of all that choose stuff! :-)
is working on a reply...