The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > Web Programming > XML / XSLT


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 11-06-2008, 02:45 PM
mochalau mochalau is offline
Novice
Join Date: Nov 2008
Posts: 1
iTrader: (0)
mochalau is on a distinguished road
XSLT assignment

I am working on my XSLT homework. I got stuck at one point and don't know what to do. Please help.

There's 3 files, golf.xml, golf.css, and golf.xsl.

This is the part I can't figure out on my xslt doc
- declare a variable named backNineScoreText, setting the value of the variable to the text string returned by calling the formatScore template using the value of the backNineScore variable for the scoreValue parameter.

I have created the named template for formatScore. Here it is:
<xsl:template name="formatScore">
<xsl:param name="scoreValue" select="golfer//score" />
<xsl:choose>
<xsl:when test="$scoreValue = 0">
<xsl:text>E</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="formatScore">
<xsl:with-param name="scoreValue" select="format-number($scoreValue, '-#;+#')" />
</xsl:call-template>
</xsl:otherwise>

</xsl:choose>
</xsl:template>


Then I try to apply this to a calcScores template (that's what the assignment wants). I highlighted the part I need to revise. I don't understand what I need to do.

<xsl:template name="calcScores">
<xsl:param name="currentRound" />
<xsl:param name="currentHole" />
<xsl:variable name="parTotal" select="sum(//par[@holeNumber &lt;= $currentHole])" />
<xsl:variable name="golferTotal" select="sum($currentRound/score[@holeNumber &lt;= $currentHole])" />
<xsl:variable name="currentScore" select="$parTotal - $golferTotal" />
<xsl:variable name="currentScoreText">
<xsl:value-of select="$currentScore" />
</xsl:variable>
<td><xsl:value-of select="$currentScoreText" /></td>

<xsl:choose>
<xsl:when test="$currentHole = 18">
<xsl:variable name="backNinePar" select="sum(//par[@holeNumber > 9 and @holeNumber &lt;= 18])" />
<xsl:variable name="backNineGolfer" select="sum($currentRound/score[@holeNumber > 9 and @holeNumber &lt;= 18])" />
<xsl:variable name="backNineScore" select="$backNinePar - $backNineGolfer" />
<xsl:variable name="backNineScoreText">
<xsl:value-of select="$backNineScore" />
</xsl:variable>

<td class="sub"><xsl:value-of select="$backNineScoreText" /></td>
<td class="final"><xsl:value-of select="$currentScoreText" /></td>
</xsl:when>
<xsl:when test="$currentHole = 9">
<td class="sub"><xsl:value-of select="$currentScoreText" /></td>
</xsl:when>
</xsl:choose>



Please also see my attachment for all my files. basically this is what i need to achieve, If the number for Round Total is = 0, it should display text string of "E". A negative value should be displayed as - value, and the positive value should be displayed as + value.

Thanks.
Attached Files
File Type: zip golf.zip (4.8 KB, 0 views)

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 07:58 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50